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.

Related Posts

Create Custom Office 2007 Installations

Today Bits of Tech brings you a video tutorial on creating custom Office 2007 installations using the Microsoft Office Customization Tool. This video takes you through the process of creating custom installs step-by-step. It also features a small segment on integrating the Office 2007 Service Pack 2 update into your installation media.

A good friend of mine loaned me his lab machine with Camtasia Studio 6 on it to create this video. Camtasia Studio is a great screencasting package, but it is a bit expensive at $299. After using his computer with the software on it, I will definitely be purchasing a copy for future video tutorials when my finances allow.

I had planned on sharing this video on YouTube, but the 10 minute video length restriction has prevented me from doing so. I will try to edit 3 minutes out of the video to fit it on YouTube, but no promises, because I don’t want to remove too much content.

ZD YouTube FLV Player

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.

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

Related Posts

Vendor for Discontinued Dell Power Supply Units

Recently, Dell has stopped providing replacement power supply units for their OptiPlex GX270 and GX280 Small Form Factor computers. Luckily, there is a vendor that supplies new parts (not refurb) for these machines. Circle Computer in Walpole, MA, has them in stock. While these computers are a bit on the old side, they function just fine for email, MS Office, and web surfing in many of my offices, so we were reluctant to dump the machines just for a faulty power supply. Contact info for Circle Computer is below.

Circle Computer
466 High Plain Street
Walpole, MA 02081

Phone: 508-668-8778
FAX: 508-668-9779
Web: http://www.circlecomputer.com/

Related Posts

  • No 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.

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.

Related Posts

Configure Windows File Sharing for Easy Migration of Data

Long ago, I learned that setting permissions on Shared Folders in Windows is a bad idea. The issue isn’t in restricting access to data, but in the way Windows handles the permissions.

I work in an Active Directory environment, with thousands of accounts in my region alone. We also rely heavily on file servers. When I first set up our file server years ago, I set all of the permissions on the share rather than on the individual files and folders.

Here’s why that’s a bad idea: When you have to move the shared folder to another drive, RAID array, or even server, you have to redo all of the permissions on the share because they don’t get copied with the folder. If you set the permissions on the shared folder and any subfolders/files, when you copy them to a new drive, those NTFS file permissions follow the data to the new location.

Here’s how I configure my file shares now. First, I create the folder I want to share. Then, right click the folder and choose Properties. Click the Sharing tab, select “Share this folder” and give the share a name. Now, click Permissions and check off Full Control, so everyone connecting to the share has full control. Click OK. These steps are illustrated below.

image image

Now, click on Security tab. Here’s where you’ll set the permissions of the actual folder. First, click the Advanced button and uncheck the box labeled “Allow inheritable permissions from the parent to propagate to this object and all child objects. Include these with entries explicitly defined here.” You will be presented with a box asking if you’d like to copy the permissions, remove them, or cancel. Choose copy, then click OK.

I want everyone to be able to access the root of this folder and the files inside it, so I’m going to click on Everyone in the top pane and ensure “Full Control” is checked. Click OK to save your changes. Now open up your shared folder and move any data you want into it. I have two folders in mine, called Subfolder 1 and Subfolder 2.

I want to restrict access to Subfolder 1 to myself and Administrators of the server only only, so I will right click the folder and choose Properties. In the Security tab, select Everyone in the top pane and click remove. You can leave “CREATOR OWNER”, “SYSTEM”, and “Administrators” there. Now, I will add my user account and assign Full Control to myself. See below, but note I have obscured my Active Directory Domain name and the server name.

image

Click OK on the window here and your permissions change will be saved. I will leave Subfolder 2 with Full Control for Everyone. Now, any users that connect to the share that aren’t Administrators of the server will receive an “Access is Denied” message if they attempt to open Subfolder1.

You can also restrict access to the whole share by assigning any permissions you want in the Security tab of the main shared folder, removing the entry for “Everyone”. This way, anyone attempting to connect to the share will be able to “Map a drive” to the share, but will receive an “Access is Denied” message whenever attempting to open it.

Using the methods above, you can safely move the shared folder to any other NTFS formatted volume on the server or even another server without worrying about having to recreate all of your permissions when you’ve moved it. All you have to do to once it’s moved is share the folder again and assign Full Control to Everyone.

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!

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

Related Posts