Skip to content

Instantly share code, notes, and snippets.

Last active Mar 31, 2019
What would you like to do?
A simple Elefant CMS backup script to Amazon S3 (requires s3cmd)
# modify these as needed
# ensure backup folder exists
mkdir -p $BACKUP
STAMP=`date +"%s - %A %d %B %Y @ %H%M"`
# export the database
cd $ROOT
./elefant export-db $BACKUP/db-$STAMP.sql
# gzip the site and database
tar -czf $BACKUP/site-$STAMP.tar.gz $ROOT $BACKUP/db-$STAMP.sql
rm db-$STAMP.sql
# backup to s3
s3cmd put "$BACKUP/site-$STAMP.tar.gz" "s3://$BUCKET/$HOSTNAME/site-$STAMP.tar.gz" > /var/log/s3backup.log 2>&1 &
# sleep for 5 seconds while file uploads
sleep 5
# remove tmp file
rm -f site-$STAMP.tar.gz
# Backup nightly at 2:00 AM
0 2 * * * /path/to/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment