Reader lucaslivingston has a WordPress blog, and wanted to make sure to back it up regularly. But while there are plenty of WordPress plugins that claim to do backups, he frankly found them daunting. Instead, he decided to create his own simple Mac-native solution using AppleScript, and then set up a daily iCal event to run that script at 4:00 every morning.
The script he came up with:
- Simulates a double-click on the alias to the Web server where his WordPress blog lives, mounting it as a WebDAV volume (just like iDisk);
- Runs the handy Unix backup command
rsync
to copy the remote contents locally; and - Unmounts the web server.
Here’s the script. Open AppleScript Editor and paste the following into a new window, then save it as an Application:
set filepath to "Macintosh HD:Users:USERNAME:Library:Favorites:www.example.com"tell application "Finder" to open filepathdelay 30do shell script "rsync -av /Volumes/www.example.com/blog/ '/Volumes/Backup/wordpress-backup'"tell application "Finder" to eject "www.example.com"
If you’re adapting it, you’ll obviously need to provide you own user name, domain, and backup destination in the script. You should be able to use this with any web server or FTP directory that you work with.
It’s important to note that this doesn’t back up the actual WordPress database. In the original hint, I mention a plug-in that I use to back mine up.
Updated 9:28 a.m. ET with note about what is and isn’t backed up for WordPress with this approach.