For my backup of content on this page I have a two-fold ‘strategy’.
- Automatic Daily ‘snapshots’ of the pure content as stored in the database keeping the last 15 versions
- Automatic full backups every 2 two days including the content in the database + complete files for the WordPress installation
1. Daily snapshots
This one is the simple part. Install the plugin ‘WP-DBManager‘, which you can use to create periodic backups on the server, where you operate WordPress or have them sent via mail (http://lesterchan.net/portfolio/programming/php/). This only does backups of the database content (mySQLdump).
2. Full Backups
I wanted to have full backups created every two days (yeah, neither too much content nor frequent changes on this page…). Full backup is database content + file system. I´m way too lazy to reinstall all the stuff with themes etc. Never tried though, if just replacing the files will work. Finding that out is sufficient, if it actually happens some day (hope not!).
The backups shall in the end land on the computer I use at home. From there I then do all the further backups.
2.1 Creating the backups
Directly on the server I use two crons, (1) for creating the database backup (2) for the files.
mysqldump -u<wordpressDatabaseUser> -p<WordpressDatabasePassword> <nameOfWordpressDB> | gzip > <target_folder>\wordpress_mysql-$(date +\%Y-\%m-\%d-\%H.\%M.\%S).gz
This will create files with names like wordpress_files-2010-03-24-02.00.01.tar.gz.
Find a more complete description here: http://www.bloggingpro.com/archives/2009/12/21/automate-wordpress-database-and-files-backup/
tar cvzf <target_folder>/wordpress_files-$(date +\%Y-\%m-\%d-\%H.\%M.\%S).tar.gz <WordpressRootFolder>/*
This will compress the complete WordPress file structure and create the compressed file in the target folder.
2.2 Copying the backups to the home PC
I first tried with WebDAV, but W7 seems to have serious issues with WebDAV and basic authentication. Thus I stuck with the FTP (I´m still thinking of switching to FTPS, but I cowardly fear the certificate stuff 🙁 ).
(1) open FTP access to your server
This strongly depends on the server you use, no description here.
(2) getting the files through FTP
I used WinSCP, which you can also script. Download and documentation here: http://winscp.net/
The script is simple assuming that the source folder on your server is directly accessed, when you log on with the user (winscp_wordpressbackup.txt):
option batch off
option confirm off
option echo on
synchronize local "<name of your local folder, where you want the backup to be stored"
synchronize local will compare, which files are on the server but not on your local machine and then only download the missing files while keeping them on the server as well.
The script is used in a batch file, which itself I schedule regularly using the standard Windows means. The batch file is even more simple than the script:
"C:\Program Files\WinSCP\WinSCP.com" /console /script="<full_path>\winscp_wordpressbackup.txt"