Tips for backing up to Amazon's S3 Service
Posted: Tue Jul 28, 2015 6:36 pm
Hi all,
I love this forum! I find loads of answers here, and people are pretty-good at answering my (sometimes dumb) questions, so I thought I'd share back with something I've learned recently. How to backup your backups to Amazon's S3:
1) Obviously, get yourself an S3 account (free for the first year!) and get your Access Key Id and Access Key. Click here for more details: http://aws.amazon.com/
2) On S3, make a unique bucket (folder) name for your backups. For this example, I'll call mine vesta-backups.
3) Install s3cmd (website here: http://s3tools.org/s3cmd) on your server. I use Ubuntu, so the command is sudo apt-get install s3cmd.
REALLY IMPORTANT PART:
4) You'll need to configure s3cmd so that it works with the VestaCP admin account. Either make sure you've SSHed in to your server as admin, or su admin to ensure you're configuring the right user. VestaCP turns off SSH access for admin by default, so be sure to edit the admin user settings to allow SSH access, even if just for this operation. If you configure the wrong user, the backup process will not work. Be warned!
5) type s3cmd --configure and enter all the requested details. You'll need to enter your S3 credentials and these are long! use <shift><insert> to paste into a terminal window.
6) s3cmd will test the connection and confirm success.
7) In /home/admin, create the following file: cron-s3sync.txt and past the following in:
8) Obviously, make sure the s3://vesta-backups is the name of your created S3 bucket. All the code from > onwards stops any reporting. Remove this and you'll receive emails regarding the process, either success or failure.
9) change the attributes of the cron-sync.txt to allow file execution: chmod 755 cron-sync.txt
10) Finally, create a CRON job in VestaCP that points to /home/admin/cron-s3sync.txt
When testing, remove the code from > to allow email reporting on success or failure, then change the CRON time to your current time +1 minute and check that everything backs up correctly. The actual code syncs the backup folder on VestaCP with S3 rather than just adding the latest backup. If you wanted different functionality, I'm sure you can figure it out.
Hope that helps!
Adam
I love this forum! I find loads of answers here, and people are pretty-good at answering my (sometimes dumb) questions, so I thought I'd share back with something I've learned recently. How to backup your backups to Amazon's S3:
1) Obviously, get yourself an S3 account (free for the first year!) and get your Access Key Id and Access Key. Click here for more details: http://aws.amazon.com/
2) On S3, make a unique bucket (folder) name for your backups. For this example, I'll call mine vesta-backups.
3) Install s3cmd (website here: http://s3tools.org/s3cmd) on your server. I use Ubuntu, so the command is sudo apt-get install s3cmd.
REALLY IMPORTANT PART:
4) You'll need to configure s3cmd so that it works with the VestaCP admin account. Either make sure you've SSHed in to your server as admin, or su admin to ensure you're configuring the right user. VestaCP turns off SSH access for admin by default, so be sure to edit the admin user settings to allow SSH access, even if just for this operation. If you configure the wrong user, the backup process will not work. Be warned!
5) type s3cmd --configure and enter all the requested details. You'll need to enter your S3 credentials and these are long! use <shift><insert> to paste into a terminal window.
6) s3cmd will test the connection and confirm success.
7) In /home/admin, create the following file: cron-s3sync.txt and past the following in:
Code: Select all
# SYNC FILES
#!/bin/bash
s3cmd sync --delete-removed -m "application/x-tar" /home/backup/ s3://vesta-backups/ >/dev/null 2>&1
9) change the attributes of the cron-sync.txt to allow file execution: chmod 755 cron-sync.txt
10) Finally, create a CRON job in VestaCP that points to /home/admin/cron-s3sync.txt
When testing, remove the code from > to allow email reporting on success or failure, then change the CRON time to your current time +1 minute and check that everything backs up correctly. The actual code syncs the backup folder on VestaCP with S3 rather than just adding the latest backup. If you wanted different functionality, I'm sure you can figure it out.
Hope that helps!
Adam