Skip to content

Instantly share code, notes, and snippets.

What would you like to do? backup script.
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/Users/ramanan/local/bin:$PATH"
# dump database, downlaod it locally, restore it over local copy
# of the database. Everything is done in /tmp/
cd /tmp/
# cd to the tmp directory on; dump the database
# out of mysql, and gzip it up.
ssh 'cd /home/ramanan/local/tmp; mysqldump funkaoshi | gzip -f > funkaoshi.sql.gz'
# copy the zip'd database dump to my computer; unzip it on my box
scp .
gunzip funkaoshi.sql.gz
# start up mysql, since I normally use postgres.
mysql.server start
# overwrite my dev database with the data from live server
mysql -D funkaoshi < funkaoshi.sql
# archive the data using git, so we keep versioned snapshots
mv funkaoshi.sql /Users/ramanan/local/backups/funkaoshi.db/funkaoshi.sql
cd /Users/ramanan/local/backups/funkaoshi.db/
git add .
git commit -m 'Import data from webserver.'
# archive files from locally
cd /Users/ramanan/local/backups/
rsync -azve ssh .
# update site prefs so we can view local copy of site from localhost/
mysql -D funkaoshi -e "update txp_prefs set val='localhost/' where name='siteurl'"
# shut down mysql
mysql.server stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.