A Basic Database and Content Backup Script

I presented an unconference session at the great WordCamp Portland and have cleaned up my backup script for WordPress (and really any db/single uploading/plugin/theme folder program). Comment here if you have any questions about how it works or suggestions for how to improve it. Like WordPress, it’s available under the GPL v2
[bash]#! /bin/sh

# config
# end config

DATE=`date +%Y.%m.%d.%k.%m | tr " " _`
echo Licensed under the GPL version 2 http://www.gnu.org/licenses/gpl-2.0.html
echo Copyright 2009 Aaron Jorbin http://aaron.jorb.in
echo $DATE start backup with mysqldump
mysqldump $DBTABLE –add-drop-table -h localhost -u $DBUSER –password=$DBPASSWORD –single-transaction > db.$DATE
echo mysqldump done, gziping it
tar cfz db.$DATE.tar.gz db.$DATE
rm db.$DATE
echo Database backup gzipped, Tarring up our WordPress folder
tar cfz mu.$DATE.tar.gz -C / $CONTENTPATH
echo copying files to backup folder
mv db.$DATE.tar.gz $DESTINATION/
mv mu.$DATE.tar.gz $DESTINATION/
echo Cleaning Up
#clean up files that are sitting there
find $DESTINATION -type f -mtime +14 -exec rm {} \;
echo Thank you for backing up WordPress.
echo —
echo The Poetic Code
echo Options, Comments, Posts and more
echo Safer then before[/bash]

Leave a Reply

Your email address will not be published. Required fields are marked *