IDG News Service >
 

Back up blog or FTP directory with AppleScript

o Kirk McElhearn
17.07.2012 kl 15:19 | Macworld.com

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.

 

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.

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 filepath

delay 30

do 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.

Keywords: Software  
Latest news from IDG News Service
Latest news from IDG News Service

Copyright 2009 IDG Magazines Norge AS. All rights reserved

Postboks 9090 Grønland - 0133 OSLO / online@idg.no / Telefon 22053000

Ansvarlig redaktør Morten Kristiansen / Utviklingsansvarlig Ulf H. Helland / Salgsdirektør Jon Thore Thorstensen