Super Simple WordPress Backup Program

Whatever you do with your computer, it’s absolutely vital to back up your data. Never is this more true than when you’re administering a website, where creating backups should be a well organised and regular procedure.

This site is no exception to that rule, so to help me out with my daily backups I’ve written a small program in the Python programming language which automates the process of archiving daily snapshots of my site. For peace of mind, I still prefer to launch and organise backups myself rather than use completely automatic solutions; this program helps make that process much quicker.


You can download the program by right-clicking here and pressing ‘Save As’/’Save Target As’.

If you want to download straight to your Linux machine from the command line, use wget:

$ wget

The program is designed to run under Linux, but theoretically it will work on any Unix system (Mac OS X, Solaris etc…) with Python installed.


All you need to feed the program is the path to your WordPress installation (the directory containing your wp-****.php files). The database login credentials are borrowed from WordPress, and the backup is placed in a date-stamped folder for easy archiving.

Each backup contains a dump of your MySQL database and a tarball of your installation directory – everything you need to restore your site in case of a disaster. The backup will be created in the folder from which you start the program.

To launch the program:

$ ./wordpressbackup /path/to/wordpress/installation

For example, if your site is located in the directory ‘/home/randymarsh/web’, the command would be:

$ ./wordpressbackup /home/randymarsh/web

If you need help or more information, use the help & about functions:

$ ./wordpressbackup help

$ ./wordpressbackup about

Hopefully this little script can help out anyone else like me who only trusts a backup they’ve done by hand. Enjoy!


3 Responses to “Super Simple WordPress Backup Program”

  1. Richard says:

    When I add this to a cron job I always get this:

    It looks like a backup might have already been run today

    I confirmed this by piping the output in the cron job. There is nothing in the folder.

    Any ideas? Otherwise very good!

    • Zebedee Pedersen says:

      Hi Richard,

      I run this particular program ‘by hand’, but I’ll add it to a schedule overnight tonight and get back to you – that message should only be issued when a datestamped folder is detected in the same folder that the program is being run from.



    • Zebedee Pedersen says:

      Hi Richard,

      The program worked fine on my server with cron – here’s the crontab entry I used (where the user is ‘randymarsh’ and the trigger time is 23:59 every day):

      59 23 * * * randymarsh cd /home/randymarsh && ./wordpressbackup www/

      The backup will be created in the same folder as the program, so put it wherever you want to create the backups, and you need to add a ‘cd’ to that folder before executing the program. In the above example, the program is located in ‘/home/randymarsh/wordpressbackup’ and the WordPress installation is at ‘/home/randymarsh/www/’.

      I’m running Ubuntu 11 64bit, FWIW. Hopefully that crontab entry is of some help to you? Let me know either way



Leave a Reply