Created
June 25, 2013 06:46
-
-
Save abegodong/5856481 to your computer and use it in GitHub Desktop.
S3 backup using s3cmd.
This file contains 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/sh | |
##################### | |
# Backup Management to S3 | |
# 2013/06/19 - Abraham Godong | |
# Require s3cmd | |
KEEP_BACKUP=3 | |
BUCKET=$1 | |
SOURCE=$2 | |
HOSTNAME=(`hostname -s`) | |
NOW=(`date +\%Y_\%m_\%d`) | |
PAST=(`date --date="-$KEEP_BACKUP days" +\%Y_\%m_\%d`) | |
echo "Uploading new Backup Files"; | |
s3cmd put $SOURCE s3://$BUCKET/$HOSTNAME/$NOW/ | |
echo "Deleting old Backup Files"; | |
s3cmd del --recursive s3://$BUCKET/$HOSTNAME/$PAST/ | |
echo "Deleting local Backup Files"; | |
rm -rf $SOURCE | |
echo "DONE!"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment