Skip to content

Instantly share code, notes, and snippets.

@jsoningram
Created September 17, 2015 04:08
Show Gist options
  • Save jsoningram/e3bfbf58e791bac79509 to your computer and use it in GitHub Desktop.
Save jsoningram/e3bfbf58e791bac79509 to your computer and use it in GitHub Desktop.
#!/bin/bash
# bckup.sh
# requires s3cmd
# backup db and site files to backups dir
# set variables
client='CLIENT'
db='DATABASE'
dbu='DATABASEUSER'
dbpw='PASSWORD'
aws='BUCKETFOLDER'
wpinstall='INSTALLFOLDER'
cd ~/$wpinstall/
dumpfile=$client`date +%F`.sql
tarball=$client`date +%F`.tar
# run the dump
mysqldump --add-drop-table -u $dbu -p$dbpw $db > $dumpfile
tar -vcf $tarball --exclude='backupbuddy' --exclude='backupbuddy_backups' --exclude='backups' .
rm $dumpfile
chmod 750 $tarball
mv $tarball ../$wpinstall/backups/
s3cmd put ~/$wpinstall/backups/$tarball s3://mc_us_standard/$aws/$tarball
echo "all done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment