Created
April 22, 2010 13:42
-
-
Save bcalloway/375234 to your computer and use it in GitHub Desktop.
s3sync backups
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 | |
# | |
# Sync's the following dirs to S3 using s3sync.rb | |
# /public/uploads | |
# /etc | |
# /usr/local/ec2onrails | |
# | |
export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXX | |
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
APPPATH=/mnt/raycom/current | |
S3BUCKET=daily.mydomain.com | |
# Backup web app | |
ruby ${APPPATH}/script/s3sync/s3sync.rb -vrp ${APPPATH}/ ${S3BUCKET}: |
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 | |
# | |
# Sync's the following dirs to S3 using s3sync.rb | |
# /public/uploads | |
# /etc | |
# /usr/local/ec2onrails | |
# | |
export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXX | |
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
DATE1=`date | awk '{print $3}'` | |
DATE2=`date | awk '{print $2}'` | |
DATE3=`date | awk '{print $6}'` | |
THEDATE="${DATE1}${DATE2}${DATE3}" | |
MYSQLHOST=localhost | |
MYSQLUSER=root | |
MYSQLPASS=password | |
BACKUPDIR=/mnt/db-backup | |
APPPATH=/mnt/raycom/current | |
S3BUCKET=backup.mydomain.com | |
# Backup database every 3 hours | |
mysqldump -u ${MYSQLUSER} -p${MYSQLPASS} -h${MYSQLHOST} -A > "${BACKUPDIR}/mysql_${THEDATE}.sql" | |
tar zcvf ${BACKUPDIR}/mysql_${THEDATE}.sql.tgz ${DIR}/mysql_${THEDATE}.sql | |
rm -f ${BACKUPDIR}/mysql_${THEDATE}.sql | |
ruby ${APPPATH}/script/s3sync/s3sync.rb -vrp ${BACKUPDIR}/ ${S3BUCKET}: |
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 | |
# | |
# Sync's the following dirs to S3 using s3sync.rb | |
# /public/uploads | |
# /etc | |
# /usr/local/ec2onrails | |
# | |
export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXX | |
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
BACKUPDIR=/mnt/db-backup | |
APPPATH=/mnt/raycom/current | |
S3BUCKET=weekly.mydomain.com | |
DBS3BUCKET=backup.mydomain.com | |
# Backup web app every week | |
ruby ${APPPATH}/script/s3sync/s3sync.rb -vrp ${APPPATH}/ ${S3BUCKET}: | |
# Find all db backups that are over 7 days old and remove them | |
find ${BACKUPDIR} -type f -mtime +7 | xargs rm -f | |
# Sync-up the db-backups dir to s3 | |
ruby ${APPPATH}/script/s3sync/s3sync.rb -vrp --delete ${BACKUPDIR} ${DBS3BUCKET}: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment