Forked from jaydrogers/amazons3move-sitesandfull.sh
Created
February 4, 2018 21:11
-
-
Save blub0hr/984788be36595d977ecd519b9a664763 to your computer and use it in GitHub Desktop.
CRON Job that will execute moving backup files to Amazon S3. Usage info here: http://serversideup.netmedia-temple-amazon-s3-backup-and-other-linux-servers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Author: Jay Rogers - [email protected] | |
#IMPORTANT -- CONFIGURATION VARIABLES | |
BACKUPDOMAIN=backup.mydomain.com | |
SITESBUCKETNAME=myserver-plesksites | |
SERVERBUCKETNAME=myserver-pleskfull | |
#Check to see if there are any individual SITES to back up. If so, move the backups to Amazon S3 | |
if [ "$(find /var/www/vhosts/$BACKUPDOMAIN/s3backups/sites/ -name "*.tar")" ]; then | |
#Make sure that CRON is able to find the AWS Configuration File | |
export AWS_CONFIG_FILE=/root/.aws/config | |
#Execute S3 moved to Bucket configured above | |
aws s3 mv /var/www/vhosts/$BACKUPDOMAIN/s3backups/sites/ s3://$SITESBUCKETNAME --recursive | |
fi | |
#Check to see if there are any SERVER backups to move. If so, move the backups to Amazon S3 | |
if [ "$(find /var/www/vhosts/$BACKUPDOMAIN/s3backups/fullserver/ -name "*.tar")" ]; then | |
#Make sure that CRON is able to find the AWS Configuration File | |
export AWS_CONFIG_FILE=/root/.aws/config | |
#Execute S3 moved to Bucket configured above | |
aws s3 mv /var/www/vhosts/$BACKUPDOMAIN/s3backups/fullserver/ s3://$SERVERBUCKETNAME --recursive | |
exit 0 | |
else | |
#If nothing exists in any of these folders, then do nothing | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment