Bits of Tech

Icon

Tips & Tricks from IT Pros

Automating WordPress Backups using Automator and Transmit

After publishing Bits of Tech with WordPress for a couple of months, I was looking for an easier way to backup my WordPress installation. From the beginning, I was running a backup every weekend using Transmit to download the whole directory housing my WordPress install, then compressing the downloaded directory, renaming it with the date and moving it to my backups folder.

Knowing that there had to be a better way, I looked at using AppleScript and Automator, eventually settling on Automator. While my process may differ slightly from yours due to differences in hosting providers, it should be very similar to how I do it. Today, I’m going to share my process step-by-step in hopes that someone else can benefit from it, and even improve upon my process.

As I mentioned earlier, I use Transmit 3 by Panic Software. The first thing I did was create a Favorite for my SFTP site. My hosting provider, DreamHost, gives you a home directory, and in that directory you can create a new directory for every domain you host, so the default path in my favorite is set to my home directory. Here’s a picture of my favorite, with my username obscured.

transmit-fav.png

First, we need to create some folders for the backups. In my user profile folder, under the Sites folder, I have created a folder called Backups. Inside Backups, I’ve also created a folder called Temp. That’s where our download will be stored temporarily before we compress it. Inside this folder, create a folder with the same name as the directory on your FTP server that houses your WordPress install. In my case, it’s bitsoftech.net. This is just a temporary folder that we’ll use later to create an action (without having to download the whole directory first).

Now that I have the favorite defined and the folders created, we can move along to creating our Automator script. Open up Automator from the Applications folder, and when you’re presented with the “Choose a starting point to open a new workflow” window, choose Custom and click Choose. You should now have a new, blank workflow.

The first step is to set up an action to download our directory containing our WordPress installation. In the left sidebar, choose the Internet category under Library. If you have Transmit installed, you should see the Transmit icon with Download Files next to it in the pane just to the right of the Library. Drag that into the large right pane of the Automator window, and you have your first action in the workflow.

Now we need to configure the Download Files action. Where it says Connect To choose Favorite. Next, choose the name of the favorite you created for Favorite. In my case, it’s DreamHost Root. For Resume Mode, choose Replace. Now we choose our destination for the downloaded files. Click Destination, then choose Other…, and you’ll be allowed to browse to your folder. Choose the Temp folder under your Backups folder. Lastly, we have to choose our Remote File Path. Click the + symbol below the Remote File Path box, and type the path to your files. Since my favorite points to my home directory, I will enter the directory that holds the WordPress installation, bitsoftech.net/. Make sure you put the trailing slash in path or Transmit will only download the folder and not it’s contents. See the example below.

dl-files-automator.png

Our next step is to create an archive of our downloaded files. Under the Library in the left pane of the Automator window, click Files and Folders, then locate Create Archive and drag that into the right pane of the window just below our Download Files action. You’ll notice that there’s now a triangle protruding from the bottom of the Download Files action connecting it to Create Archive. This means that the output of Download Files—the directory we downloaded—are the input that Create Archive will use.

In the box labeled Save As, we will give the archive a name. I am using Bitsoftech-(date)-(time).zip. The (date) and (time) are variables that Automator will populate itself. To create the name, type the name you want to use, such as Bitsoftech-, then click the Variables button above Library in the left pane of the Automator window. Choose Date & Time, and drag Today’s date to the Save As box in the Create Archive action on the right. Click the little white triangle inside the Today’s Date bubble you dragged over and choose Edit. From the Format drop down menu that appears, choose Custom Format. Now drag the Month, Day of Month, and Year bubbles into the box above them. Next, click the little triangle inside the Month and Day of Month bubbles and change the format to “01″ and “05″, as shown below, then click Done.

date-variable.png

Now, back in the Save As box in the Create Archive action, type another hyphen, then go back over to the Variables under Library and drag Current time over into the Save As box. Click the little triangle in the Current Time bubble, choose Edit, then Custom Format from the drop down menu. Drag the Hour and Minute to the box above them. Inside the hour bubble, click the triangle and choose “01-24″ so our hours are displayed in military time. Leave the Minute bubble as it is, then click Done. After the Current Time bubble in Save as, type .zip. From the drop down menu next to Where, choose Other… and navigate to your Backups folder or wherever you want to store the archive. Check off Ignore Unreadable Items, and your action should look similar to the image below.

create-archive-action.png

Now that our download and archive actions are complete, it’s time to do some cleanup. Choose Actions from just above Library in the left pane again, select Files and Folders, and drag Get Specified Finder Items over to the right pane of the window just below Create Archive. Now, from the Action menu at the top of the screen, choose Ignore Input. You’ll notice that the triangle connecting Create Archive and Get Specified Finder Items disappears and the two are no longer linked. This is very important, otherwise Get Specified Finder Items will take the items you specify and the archive you just created and move them to the trash in our next step.

Click the Add button at the bottom of the Get Specified Finder Items action, then navigate to your Temp folder, select the directory inside it and hit Add. Your action should now look like the image below.

get-items.png

Now, we’re going to move that folder to the trash. Back in the left pane under Library, then Files and Folders, drag Move Finder Items to Trash just below your Get Selected Finder Items action. You’ll notice that Get Selected Finder Items and Move Finder Items to Trash are linked. This means that the items you selected in the Get Selected Finder Items will be moved to the trash. This cleans out your Temp folder for the next time you run the workflow.

The last action in the workflow is to quit Transmission. Under Library in the left pane, click Utilities, then drag Quit Application to the right pane below Move Finder Items to Trash. From the drop down menu, choose Transmit. If it doesn’t show up, choose Other… then navigate to your Transmit application. Uncheck Ask to save changes, and your workflow is complete.

Now, we have to save our workflow. From the File menu at the top of the screen, choose Save As…, then change the File Format to Application. Give it a name at the top of the window—I used “Bits of Tech Backup”—navigate to where you want to save it, then click Save.

Now you have a simple one-step process to back up your WordPress installation. You can manually run this backup by double clicking the icon, or you can schedule a cron job to run it automatically.

Technorati Tags: Apple, Automator, Backup, WordPress

Related Posts

Arranging Menu Bar icons in Leopard

Got a few icons in your Menu Bar and you’d like to change the order they’re displayed in? You’re in luck, they’re fairly easy to move around. Just hold your Command key and drag them into the order you prefer.

Want to get rid of an icon? Hold the Command key and drag it off the menu bar. Gone!

This method doesn’t work with the Apple icons, but not with all apps. Some exceptions to this method are Google Notifier, Tweeie, and Adium. To rearrange these, exit the apps and relaunch them in the order you’d like them to appear from right to left. If they are apps in your Startup Items, you can change the order they launch in to reorder them in the menu bar.

Technorati Tags: Apple, Mac OS, Menu Bar

Related Posts

Disable Leopard’s 3D Glass Dock

I’ve never been a big fan of the Leopard 3D glass dock effect, preferring the 2D dock effect that you see if you place the dock on the sides of your screen. While I personally keep my dock on the left side of the screen, you can get the same 2D effect at the bottom of your screen using a fairly simple terminal command.

Just open your Terminal app (located in Applications:Utilities), then paste in the following command and hit enter:

defaults write com.apple.dock no-glass -boolean YES; killall Dock

Your dock will exit and reopen in 2D mode, as shown in the image below.

dock2d

To disable the 2D effect, simply paste the same command into Terminal, replacing “YES” with “NO”.

Technorati Tags: Apple, Dock, Mac OS

Related Posts

Apple Bumps Up Processor, RAM & Hard Drive on White MacBook

Apple has given a slight bump up in power on the white MacBook available in the Apple Store. The changes are from 2.0GHz processor to 2.13GHz (negligible, I know, but it’s something), RAM from 2GB DDR2 667MHz to 2GB DDR2 800MHz, and the hard drive is now 160GB, up from 120GB. It’s good to see that Apple is still paying attention to their entry level MacBook, even if it is still $999.

Technorati Tags: Apple, MacBook

Related Posts

Checking Your Mac Notebook Battery Health with coconutBattery

Is your Mac notebook’s battery not lasting quite as long as it used to? Just curious about or obsessive over keeping your laptop healthy? Christoph Sanai at coconut-flavour.com has written an excellent little utility for checking the current charge and capacity of your Mac notebook’s battery.

Available at coconut-flavour.com, coconutBattery is a free utility for viewing battery data on your Mac notebook. Below is a view of my battery’s current info.

coconutBattery.png

As you can see in the bottom portion of the window, my Mac is 6 months old. Over those 6 months, I’ve put the battery through 31 load cycles. Load cycles are the number of times your battery has been discharged and recharged. Over time as you charge and discharge your battery, the capacity becomes diminished and the battery won’t last as long as when it was new.

In the screenshot above, you’ll notice that the original battery capacity for my laptop—a MacBook 13″ Unibody from Late 2008—was 4100 mAh, or milliamp hours. The current capacity is 4104 mAh, so the health of my battery is 100%. It’s common to see the current battery capacity fluctuate a bit between charges.

To ensure accurate display of remaining capacity and the longevity of your battery, it’s best to calibrate the battery once a month or so. It may sound complicated, however it’s very easy. In the MacBook, MacBook Pro, and PowerBook G4 15-inch Dual Layer SD, the battery is calibrated as follows.

  1. Completely charge the battery.
  2. Completely discharge the battery. Use the computer off the charger until you get the warning that the computer is running on reserve power and will sleep soon. Continue using the computer until it goes to sleep, powering itself off.
  3. Allow the computer to remain powered off for 5 hours.
  4. Connect the charger and completely charge the battery.

For older PowerBook G4’s and iBooks, the calibration method differs slightly, and you may find more informaton here: Apple Portables: Calibrating your computer’s battery for best performance.

Technorati Tags: Apple, Battery, MacBook

Related Posts

Apple Releases Mac OS X 10.5.7 Update

This afternoon, Apple released Mac OS X 10.5.7 Update. It is now available via Software Update and as a standalone installer in the Downloads section of the Apple website.

From the Apple website: The Mac OS X 10.5.7 Update is recommended for Mac OS X 10.5 Leopard and includes general operating system fixes that enhance the stability, compatibility, and security of your Mac. For detailed information about security updates, please visit this website.

I started to download the update via Software Update, but the download was fairly slow—it would have taken roughly 2 hours to download. I quickly gave up on Software Update and grabbed the update from the Apple Downloads site. This download was very quick. I averaged 2.0MB/s—yes, that’s Megabytes—on my 20Mbps cable modem. The update from 10.5.6 to 10.5.7 weighs in around 440MB, so if you’d like to get it installed this evening, I’d suggest using the Apple Downloads site. Links provided below.

 

About the Mac OS X 10.5.7 Update:
http://support.apple.com/kb/HT3397

Standalone Update (from 10.5.6):
http://support.apple.com/downloads/Mac_OS_X_10_5_7_Update

Standalone Combo Update (from any previous 10.5 version):
http://support.apple.com/downloads/Mac_OS_X_10_5_7_Combo_Update

Technorati Tags: Apple, Leopard, Mac OS

Related Posts

Archives

Follow Me on Twitter: @bill_clark