Hawk in the trees

We have a few hawks in the area but they mostly hang out near the wetlands behind us. In this case (see upper right of photo) this one flew to the front. Hunting, I think, chipmunks. 

IMG 4418

Backing up my web sites using Transmit

After 5 years (!?) I thought I would automate the backing up of my (very simple) web sites.

I’ve been using Interarchy for a very long time but I thought I would use Transmit to do this.

A few caveats to get started:

  1. What I’m actually doing is synchronizing the remote site to the local location
  2. That means that I started Transmit and added a Favorite to the app represents the top level of the FTP location
  3. Most of the script comes from Panic samples called ‘Transmit 4 AppleScript samples’. I added a few lines to set the AppleScript timeout and loop through the sites
  4. This is an AppleScript. I’ll probably convert it to Javascript at some point.

I’ve included the script below.

Once I got the script running the way I wanted it to I saved the script as an ‘Application’.

I then went over to Automator and created a “Calendar Alarm” item. I used the ‘Run Application’ event and selected my Script application. Hit save and Calendar will fire up and an event will be created. Note that event creation will trigger the script attached to it. Wish it didn’t do that but whatever. One other thing to mention is that the Calendar that is created is local to the machine where you used Automator to create the Calendar Alarm.

Set the schedule for the event and you are done. The next time the event date/time hits the Script application will fire and bam… your files will be backed up.

There are a lot of tweaks that the script could use that I will add as time goes on.

Also note that you need follow through on other steps to make sure that the data is good such as restoring the data, checking its ok, etc, etc.

Now… to back up those MySQL databases!

Here’s the script:

— Connect to FTP Server and sync remote directories to local directories
— 2010 Panic Inc.
— Mild modifications made by JAG, 2018

<p>tell application &quot;Transmit&quot;<br />
  with timeout of (15 * 60) seconds<br />
  activate<br />
  tell application &quot;Transmit&quot;<br />
-- Prevent interactive alerts from popping up during script execution<br />
set SuppressAppleScriptAlerts to true</p>
<p>-- Set some variables to values to be used later in the script<br />
set myFTPServer to item 1 of (favorites whose name is “NameOfYourFTPLocation&quot;)<br />
set pathToMainBackupDirectory to &quot;/Volumes/Drobo/Backups - Web Sites/&quot;<br />
set listOfSites to {“directory_1&quot;, “directory_2&quot;, “directory_3&quot;}</p>
<p>-- Start working with Transmit<br />
-- Loop through the list of sites, change the remote and local browser path and sync<br />
-- the remote site to the local site<br />
repeat with a from 1 to length of listOfSites<br />
set theCurrentSiteListItem to item a of listOfSites<br />
tell current tab of (make new document at end)<br />
-- Connect to the FTP Server<br />
connect to myFTPServer</p>
<p>-- Change the path for the remote browser to correct path on the FTP server<br />
change location of remote browser to path theCurrentSiteListItem</p>
<p>-- Chagne the path for the local browser to location of the backup<br />
change location of local browser to path &quot;/Volumes/Drobo/Backups - Web Sites/&quot; &amp; theCurrentSiteListItem as string</p>
<p>-- Tell Transmit 5 to sychronize the remote location to the local location<br />
synchronize remote browser to local browser</p>
<p>-- Close the remote browser window<br />
close remote browser<br />
end tell<br />
end repeat<br />
set SuppressAppleScriptAlerts to false<br />
end tell<br />
end timeout<br />
end tell</p>