Backing Up Unity Media

Every once in a while it becomes necessary to back up all of the media on your Unity, and this is a fairly big task. It can be terabytes of data that you need to transfer to a backup drive or drives, and there are better ways of doing this than just drag and drop. So whether the backup is needed at the end of the show for archival purposes, or somewhere in the middle because you’re switching cities and need to ship the Unity to a new office, here’s a little script I wrote to help accomplish this task safely and reliably. Some knowledge of Terminal is required (but not too much).

Backup Strategies

The script I’ve detailed here does rely on a bit of manual work. You will need to do the math to figure out which and how many workspaces from your Unity will fit onto the external drive(s) you have available. The Unity Administration Tool should help you out with that.

This script should be modified and run once per external drive. So once you know how you want to distribute your Unity workspaces across your external drives, then you should only set this script up for one volume at a time. When it finishes and is successful, change the Target Volume and Source Directories in the script file and execute it again.

rsync_dir_all Bash Script – Mac only

This is the contents of the script. Before using it, you need to modify it to suit your Unity setup. In a text editor such as jEdit, change the following items:

  • Target Volume: This is the name of the Firewire drive to which you will be backing up all or part of your Unity. This volume should have no spaces or special characters in its name
  • Source Directories: These are the names of the workspaces you want to copy to your Target Volume. They can be listed in any order, and should be separated by a space.
#!/bin/bash

# Base Path for Source Volumes. If you're on a Mac connected to the Unity, this should not change
basepath="/Volumes/"

# TARGET Volume for Backup. This should be the path and name of your drive as it appears on your desktop.
# You should remove any spaces from that name or replace them with "_", as you can see below.
targetpath="/Volumes/Firewire_Hard_Drive_Name_Here"

# SOURCE DIRECTORIES: Start looping through directories.
# Each Unity workspace you want to back up should go here, separated by a space.
for directory in Media_1 Media_2 Media_3 Media_4 Media_5
do

# RSYNC COMMAND
rsync -avP $basepath$directory ${targetpath}; STATUS="$?"

# TELL WHETHER THE BACKUP OPERATION WAS SUCCESSFUL OR NOT.
if [ "$STATUS" = "0" ]
then

# If you have the Growl command-line utilities installed, this will create a notification
growlnotify -n rsync -s -m "$directory copied to $targetpath successfully" "Rsync Success"
else
growlnotify -n rsync -s -m "$directory error" "Rsync Failure"
fi

done

When this is done, go to Terminal and cd to the directory where this script is stored. Run the command ‘./rsync_dir_all.bsh’ and watch the transfer fly. If for whatever reason you need to stop the copy and restart it later, just run the command again and it will pick up where it left off.

GrowlNotify

The bonus feature I coded into this script is a sticky Growl notification for each volume’s success or failure in transferring to the Target Volume. That way you can set off the backup on a Friday night, come back in on Monday, and see how each volume faired. It relies not only on Growl being installed, but also the growlnotify command-line program. See the Growl homepage for more details on how to set this up.

How Not to Back Up Your Unity

Do not drag and drop multiple Unity workspaces onto your poor external hard drive. Not only will this slow you down by attempting to copy that much data simultaneously instead of sequentially, but the drag and drop copy function gives you no accountability in case of a failure. You will spend a lot of time either recopying files you don’t need to, or trying to figure out where your copy stopped so you can start up again from that point. Furthermore, Avid MediaFiles folders can have thousands of files in them, and it bogs down OSX to display the filenames of all of these files in a Finder window. It bogs down OSX even more if you then copy thousands of files from one window to the other and force Finder to now continually refresh a second Finder window with thousands of filenames and icons as the copy progresses. It may even crash because of it. I can’t stress enough how bad an idea it is to try a drag and drop copy of that much material.

rsync is your friend, and it will help you tremendously if you use it. In case of an interrupted copy process, it can determine much more quickly than you can what files are already in good condition on your Target Volume, and skip directly over them to start copying where it left off. The output it gives you in the Terminal is also very detailed and will let you monitor the progress of your backup with much more information. It’s been around in the Unix world for years and is a very stable program, so it’s well worth taking advantage of it.

Attachments:

No Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.