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.
For Debian and Ubuntus3tools.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 :-)
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.chmod +x s3mysqlbackup.sh
chmod +x s3backups.sh
# Run the scripts
./s3mysqlbackup.sh
./s3backups.sh
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 ``` ```### Deny public access to shell files Order allow,deny Deny from all ```If this needs anymore clarification please let me know!
[s3cmd command examples](https://linuxconfig.org/getting-started-with-aws-s3cmd-command-by-examples)