quick & dirty:
#!/bin/bash # # Simple script to backup a wordpress installation. # # That is: # # mysqldump of database schema # mysqldump of database entries # compressed tarball of database backups and wordpress itself # # DATESTAMP=$(date +"%Y%m%d") DBNAME="wordpress" SRCDIR="/path/to/wordpress" TARGET="wordpress-$DATESTAMP" if [ ! -d $TARGET ]; then mkdir $TARGET else echo "Error: working directory exists, bailing out." exit 1 fi echo "Dumping WordPress MySQL DB scheme..." mysqldump --no-data wordpress -u wordpress -p > $TARGET/wordpress-$DATESTAMP.schema.sql echo "Dumping WordPress MySQL DB data..." mysqldump --no-create-info wordpress -u wordpress -p > $TARGET/wordpress-$DATESTAMP.data.sql cp -rp $SRCDIR $TARGET if [ ! -f $TARGET.tar.gz ]; then tar cfvz ./$TARGET.tar.gz $TARGET if [ $? -eq 0 ]; then echo "Archive created successfully, removing working directory." rm -rf $TARGET exit 0 fi else echo "Error: target file exists, bailing out." exit 1 fi