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

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

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

Change the Default Screen Capture Format in Mac OS

To change the default file format of screen captures taken on your mac, you have a couple of different options. The quickest of them is using the Terminal app. To change the default format, use the following command.

defaults write com.apple.screencapture type format

You can replace format with any of the following formats: png, gif, bmp, jpeg, jpeg 2000, pdf, psd, sgi, tiff, pict, or tga.

Another option, if you’re not comfortable using the terminal, is to use the excellent maintenance program, OnyX.

First, fire up OnyX, then click the Parameters button in the toolbar. About halfway down on the right side, you’ll find the Screen Capture Format control, circled in red below. Select your desired format from the popup menu, then exit OnyX.

OnyX-screencap.png

That’s all there is to it!

Technorati Tags: Mac, Terminal

Related Posts

Editing the Terminal Banner (Message of the Day)

I like to have one of my favorite quotes displayed each time I open a new Terminal window. It’s pretty easy to do this, and I’m going to show you how.

First, you’ll need to open your Terminal app, which is located in the Utilities folder. To get there quickly, hit Command-Shift-U while in Finder. This will open the Utilities folder. Now open up Terminal.

Next, you need to open the /etc/motd file in vim. Type the following command at the prompt and hit return:

sudo vim /etc/motd

You’ll be prompted for your password, and after you enter it you’ll be presented with the motd document. If there’s anything in there, tap the Esc key, then double tap the D key to remove the existing text line by line. If there are multiple lines, keep double tapping D until the document is cleared.

Now, hit Esc then the A key. This will enter insert mode. Insert a blank line by hitting return, then enter the text you wish to be displayed. Make sure to leave a blank line at the end as well. When you’ve finished, hit Esc then hold Shift and double tap Z. This will save and exit.

Hit Command-Q to quit terminal, then reopen it and you’ll see your banner text at the top of the window above the prompt, as shown below:

terminal-motd.png

Technorati Tags: Mac, Terminal

Related Posts

Hide a BootCamp Windows Partition from the OS X Desktop

After loading Windows 7 RC on my MacBook in BootCamp, I noticed that the partition shows up on the Mac OS desktop. I leave the icons for hard drives on the desktop, but since I don’t use the Windows partition from inside OS X, I was looking for a way to hide it from the desktop.

After digging around on Google a bit, I found a few ways to do it. The easiest of which is to simply log into your Windows environment and rename the C drive to something like .Windows. This works because UNIX- and Linux-based systems assume that any file or folder beginning with a . (period) are meant to be hidden. The advantage to this method is the change doesn’t cause the partition not to be mounted, so it’s still accessible if you want to copy files from the NTFS partition.

Another method, which I came across on Chris Brewer’s Garbage In, Garbage Out blog, uses a command line program from Apple’s developer tools called SetFile to hide the partition. Have a look at the post here: BootCamp: Hide a Windows XP volume on Mac desktop. Keep in mind that to use this method, you will have to install Apple’s Developer Tools, available for download from Apple’s website or from the DVD’s that came with your new Mac.

Technorati Tags: BootCamp, Mac

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

10 Programs I Can’t Live Without

Anyone who uses a computer for work or personal use on a regular basis has a group of preferred programs to use. Some of us have some programs mandated by our employers, and some of us are free to choose what programs—or even computing platforms—we use. I’m lucky enough to be employed by a company that allows employees to choose what programs they use for the most part.

In no particular order, here are the 10 programs/software packages I absolutely cannot live without. I use both Windows Vista and Mac OS X, so you’ll find programs from both platforms in my list. To keep this post short and not take up too much of your time reading it, I won’t go into too much detail as to why each program has made it onto this list. You can rest assured though, I will save that detail for individual posts later.

  1. Microsoft Outlook 2007 (Windows)
    While we use Microsoft Exchange 2007 as our email server platform at work and Outlook is the best way to go for an Exchange client, I could use any POP3/SMTP or IMAP capable client to check my email. Even given this choice, I stick with Outlook 2007. I prefer Outlook because of the tight integration with Exchange, and because it has everything I need—email, calendar, tasks, and notes—all in one package.
  2. Trillian (4.0 beta) (Windows)
    I have been a Trillian user since their early days, and haven’t bothered with other IM clients. Trillian Pro allows me to use my two primary instant messaging platforms—AIM and Yahoo!—without having two programs running. I’ve been testing 4.0 (Astra) since it entered alpha stage, and now in it’s beta stage. Even in it’s alpha form, Trillian 4 has proven itself a stable and full-featured IM client.
  3. Windows Live Writer 2009 (Windows)
    While I’ve only just started blogging, Windows Live Writer has quickly become my remote publishing client of choice for my WordPress blog. It’s clean interface and ease of use has claimed it spot on my most frequently used programs list.
  4. PuTTY (Windows)
    I use PuTTY to manage all of the Cisco network gear I work with, as well as to log into the Ubuntu server in my office. It’s a very simple, yet powerful SSH client that just works. It has the ability to connect to telnet, SSH, and even Serial clients, and also has the ability to save connection profiles.
  5. Launchy (Windows)
    Launchy is an open-source Windows alternative to the Mac app, Quicksilver. It allows for keyboard launching of programs, opening documents, and even custom triggers. It has a plug-in architecture and there are quite a few useful plug-ins available. I use it in conjunction with the PuTTY plug-in, which allows me to open an SSH session to a host using the keyboard shortcut to invoke Launchy and then type ssh hostname followed by the enter key. I also use a custom trigger that allows me to launch Microsoft Remote Desktop connections via the Launchy interface.
  6. Quicksilver (Mac)
    Quicksilver is a very powerful keyboard launcher for Mac. At the moment, I haven’t delved too deep in setting it up on my machine. I’m only using Quicksilver as a keyboard launcher. I have quite a few applications that I don’t keep in my dock, but use somewhat regularly. It’s handy to be able to easily launch an application by invoking Quicksilver and typing the first few letters of the name. I’m sure it’s capable of much more, but I haven’t really played with it beyond that.
  7. Tweetie (Mac)
    Tweetie is by far my favorite Twitter client out of all of the options available for Mac and PC. It’s slick interface is both great looking and easy to use. Multiple account support is great, and you can choose from a number of URL shortening and picture sharing services. All in all a great looking, feature packed client. The folks at Atebits definitely put a lot of thought into this app.
  8. Firefox (PC & Mac)
    Firefox is my browser of choice, though Internet Explorer 8 is a close second. The extensibility of Firefox is the clincher for me. Having the ability to add functionality to the browser via extensions is an enormous advantage over IE. A few of the extensions I use are GMail Notifier, Greasemonkey, Right-Click-Link, Google Redesigned, Extended Statusbar, Delicious Bookmarks, and PDF Download.
  9. VNC (PC & Mac)
    I use UltraVNC on my PC, and Chicken of the VNC on my Mac. Having the ability to remote control PC’s is an absolute must in my job. We load UltraVNC Server on each of the desktop and notebook PC’s at my company, and we use OSXvnc as the VNC server on the single Mac at each location. Being able to control PC’s or Mac’s from either platform is a big help as well, so I don’t have to have a particular computer with me to provide support.
  10. SplashID iPhone & Desktop (iPhone, PC, Mac)
    Between my personal data from online banking, credit card websites, forums, and other sites, to my business needs for multiple logon accounts, service accounts, and other passwords, SplashID remembers them all. I have a copy of the desktop version on my PC and another on my Mac, and I routinely sync between the three. I got hooked on password managers back when I used CryptMagic on my old BlackBerry, but since moving to the iPhone, I settled on SplashID since it most closely resembled CryptMagic. The fact that it’s available on both Mac & PC was the deal-maker for me, as I routinely use both platforms.

So there you have it, my list of the 10 programs/software packages that I can’t live without. If there’s a piece of software you can’t live without, I’d love to hear about it. Leave a comment and I’ll be sure to check it out.

Technorati Tags: Mac, Outlook, Software, Trillian, Windows

Related Posts

Archives

Follow Me on Twitter: @bill_clark