Skip to content

Scripts to help your Linux-AWS instance back up to your S3 buckets, with help from some cron jobs.

Notifications You must be signed in to change notification settings

alexdahlman/AWS-S3-Backups

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

AWS-S3-Backups

Scripts to help your Linux-AWS instance back up to your S3 buckets, with help from some cron jobs. I had to create a solution to help keep monthly backups of our website and help create a new 3-2-1 backup practice. Hopefully this comes in handy to everyone! I took a lot from this gist by oodavid and his s3mysql backup solution.

Install S3cmd

For Debian and Ubuntu

s3tools.org is a great resource for all of this, with the majority of the guide being built on alot of their info.

#Import S3tools signing key:
wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | sudo apt-key add -

#Add repo to sources.list: 
sudo wget -O/etc/apt/sources.list.d/s3tools.list http://s3tools.org/repo/deb-all/stable/s3tools.list

#Refresh package cache and install the newest s3cmd:
sudo apt-get update && sudo apt-get install s3cmd

# Setup s3cmd
s3cmd --configure
    # You’ll need to enter your AWS access key and secret key here, everything is optional and can be ignored :-)

For CentOS

# Install s3cmd
cd /etc/yum.repos.d/
wget http://s3tools.org/repo/CentOS_5/s3tools.repo
yum install s3cmd
# Setup s3cmd
s3cmd --configure
# You’ll need to enter your AWS access key and secret key here, everything is optional and can be ignored :-)

Scripts

These two scripts do all the work for a monthly mysql and full htdocs backup. This works great if you have a wordpress site or small site that doesn't hold volitile information and doesn't require a constant backup.

Don't forget the permissions to these to run.

s3backup.sh

s3mysqlbackup.sh

chmod +x s3mysqlbackup.sh
chmod +x s3backups.sh
# Run the scripts
./s3mysqlbackup.sh
./s3backups.sh

Cron

Runs at midnight first of the month.

```crontab 0 0 1 * * bash /location/s3mysqlbackup.sh >/dev/null 2>&1 0 0 1 * * bash /location/s3backup.sh >/dev/null 2>&1 ```

Safety

```### Deny public access to shell files Order allow,deny Deny from all ```

If this needs anymore clarification please let me know!

Helpful Links

[s3cmd command examples](https://linuxconfig.org/getting-started-with-aws-s3cmd-command-by-examples)

Repos for s3cmd

s3cmd info

Tar issues

About

Scripts to help your Linux-AWS instance back up to your S3 buckets, with help from some cron jobs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages