I needed to snag backups of all my edit systems, but here’s the catch – I don’t want to install any third-party backup application nor did I want a setup that would require an editor to remember to run an application or something like that.
How to do this on an OSX machine? Easy. Use cron, a terminal script and a simple third-party automounting application to get the job done. More after the jump.
UPDATE: I want to point out that, at this point, the script is just backing up the FCP Projects folder every night. I run CarbonCopyCloner/SuperDuper backups of the entire system drive every few weeks to a second internal drive.
First things first, a little about my setup: I have 9 FCP systems to manage. That’s 9 suites each churning out edits everyday (sometimes). I needed a way to make sure everything was getting backed up with zero intervention on anyone’s part – it had to be automatic and foolproof.
All my systems are on the same LAN segment. They all can “see” a shared drive, we call it the L Drive ’cause that’s how it shows up on the Windows machines folks have at their desks. Nice feature that, sharing a drive between the Windows and Macs. It means you don’t have to muck about with file sharing on individual machines. You can just shove a file to the L drive and then it can be accessed from any machine that can see it, automatically.
I digress, so I’ve got this shared drive & everyone can see it. It would make a perfect repository for some sort of daily backup. But how to make that happen with zero intervention on anybody’s part. I’ve been in facilities that relied on the editor manually backing up their projects and discovered the hard way the problem with that – people don’t remember to do it. Inevitably, you would run in to a situation where you needed a copy of the previous day’s work and nobody remembered to make a back up copy. In fact, nobody had backed up the project since it started editing 6 weeks ago!
I know there are third-party backup scheduling applications out there, but that would require having to leave the application running all the time or getting the editor to make sure that it is running when they walk out for the day. Again, not a likely scenario.
I looked through the tools that come pre-installed on every OSX system: Applescript, Automator, Terminal, Cron, etc. After trying to teach myself Applescript and failing because I just didn’t have the time to learn all that I needed to know, and briefly attempting to use an Automator action, I hit upon the idea of using a Terminal Command or Shell Script. My knowledge of Batch files from my early DOS days *would* be useful again!
The script would need to copy everything from a selected directory to a remote directory. It would be nice to identify what system it came from and to create a copy of the previous day’s backup – that way I’d get 2 days worth of backups stored remotely. I also threw in a third local copy to an internal backup drive as an added bonus.
Here’s the code from the shell script:
echo STAB...a "(really)" simple script to automate backups.
echo version 12.05.06
echo created by Ben Howard, 2006
# local system name
# local user name
localuser=`id -g -nr`;
# source path
# Because of case problems, this might need to re-written using awk to extract proper path to server
# Remote Backup Path
# Local Backup Path
echo `date` $localname" started Backup" >> /Volumes/adv_prod/_FCP_Project_Backups/bu_logfile.txt
echo Using these values:
echo User: $localuser
echo MachineID: $localname
echo Source Path: $sourcepath
echo Target Path: $targetpath
echo Local Target Path: $localtargetpath
echo Making $targetpath dir -if it doesnt exist
mkdir -p $targetpath
echo Renaming $targetpath$localname".zip" to $targetpath$localname"OLDER".zip
mv -f $targetpath$localname".zip" $targetpath$localname"OLDER.zip"
echo Now we zip it and send it to the target path...
# Using zip because my archives are sent to a Windows file server, Ben
time zip -r $targetpath$localname $sourcepath
# Uncomment your favorite flavor of copying, or leave untouched to disable
# This is really specific to the configuration of my machines, so YMMV, Ben
echo Now making local backup copy to "$localname"Backup...
#cp $sourcepath $localtargetpath$sourcepath
ditto -V -rsrc $sourcepath $localtargetpath$sourcepath
#/usr/bin/rsync -a -vvvv -e ssh $sourcepath $localtargetpath -E --progress
echo Backup complete...
echo `date` $localname" Backup COMPLETE" >> /Volumes/adv_prod/_FCP_Project_Backups/bu_logfile.txt
echo If you see this, it is because the backup script on this machine
echo has run overnight. If there are no errors listed above, you may
echo quit Terminal and be happy knowing your projects are backed up...
echo If you see something like "Error" or an exitcode that is not 0
echo come get Ben Howard and show him this screen before you quit it.
Read through it and you’ll see that it is super-basic. I’ve liberally commented things both for my future tinkering and so you can see why I did something a certain way. There are also a lot of extra “echo” commands so that I could see what was happening when as I developed this in the Terminal, you could delete many of them. The script uses a few command line tools to figure out what machine it is and then saves a .zip archive to a directory that matches the machine name. It also creates a log file entry at the start and end of it’s run, so you can see if a machine might be starting a backup and failing or if it doesn’t run at all.
Now, since this all is dependent on the L drive being mounted, how do I make sure the remote drive is mounted? Use Automountmaker. It is super-easy to use and you can run it as a Startup Item or invoke it as part of timed execution of the backup script.
Oh yeah, the timed execution part comes in by using a built-in OSX utility – cron. cron is a application that is always running when your machine is turned on (and not in sleep mode). You can set it to run applications at certain times (even certain days of the week or month). I learned how to use cron by typing “man cron” in the Terminal & by downloading Cronnix (a GUI frontend for the cron utility.
All anybody has to do to get this to work is leave the edit system turned on when they leave.
Good luck and may your backups be frequent & often!