07.05.08
WordPress Backup Script
This is a small script I’ve written to automate my server-side backups of my blogs. It creates a backup of both the database and the actual WordPress files.
#!/bin/bash # (C) 2008 Guy Rutenberg - http://www.guyrutenberg.com # This is a script that creates backups of blogs. DB_NAME=guy_blog DB_USER=guy_root DB_PASS=**** DB_HOST=localhost #no trailing slash BLOG_DIR=/home/guyru/guyrutenberg.com BACKUP_DIR=/home/guyru/backups echo -n "dumping database... " mysqldump --user=${DB_USER}|> --password=${DB_PASS}|> --host=${DB_HOST}|> ${DB_NAME}|> \ | bzip2 -c > ${BACKUP_DIR}|>/${DB_NAME}|>-$(date +%Y%m%d).sql.bz2 if [ "$?" -ne "0" ]; then echo -e "\nmysqldump failed!" exit 1 fi echo "done" echo -n "Creating tarball... " tar -cjf ${BACKUP_DIR}|>/${BLOG_DIR##*/}-$(date +%Y%m%d).tar.bz2 ${BLOG_DIR} if [ "$?" -ne "0" ]; then echo -e "\ntarball creation failed!" exit 1 fi echo "done"