A simple bash script to take automated offsite backup of sites created with EasyEngine
- First of all install and configure s3cmd on your server
apt-get install s3cmd
s3cmd --configure
- Create backup.sh in your /root/backups directory:
vi ~/backups/backup.sh
- Paste this script in to this opend file: press i and then click with right mouse button
- Save and close this file: press ESC, now write wq, press ENTER
OR
Simply copy this script from GitHub
mkdir -p ~/backups/ && wget -O ~/backups/backup.sh https://raw.githubusercontent.com/kamdhenu/EasyS3/master/backup.sh
-
Edit the downloaded
backup.sh
file and enter your S3 Bucket name -
Make this script executable:
chmod +x ~/backups/backup.sh
- If you want to exclude certain files/directories, create a file called "exclude.txt" inside the backups directory
- Add pattern/path for all excluded files/directories in this file (one per line) and save it
- Run this script to start backup immidiately
FINALLY
- Set cron job to automate the backup:
/root/backups/backup.sh >/dev/null 2>&1
IMPORTANT
You may also want to setup an Object Expiration Policy for your s3 bucke to auto delete/archive old backup files from your bucket.