EditShare Project Backup automation

Sometimes you just need to make your life easier and let’s face it, EditShare do not do that unless you pay them large chunks of cash. You hand over teh cash, they give you EditShare Ark which sucks balls for the most part as it’s based on Bacula and not Amanda (They won’t tell you this!).

One of the little jobs we need to do is backup the users project files nightly really quickly and painlessly. We only keep hold of three days worth but you may require X days, you can adjust the below to suit your needs. Save this out as backupprojfiles in to /usr/local/bin:

getdate=$(date +%F)

echo Hello. Here we go... > $logfile

# First we mount the backup NAS
mount $mountpoint >> $logfile

# check if mounted
if mount | grep backupnas > /dev/null; then
echo "Mounted like a cowboy, yeehaw..." >> $logfile
echo "Not mounted, bailing out!" >> $logfile
/usr/local/bin/sendEmail -f [email protected] -t -u "BACKUP FAILED" -m "Mount point wouldn't mount. It might be worth checking out" -s -o tls=no
exit 1

# We need to handle some filenames with spaces in a find search

# find those files and folders to rsync to backup one raid at a time
echo Hunting for Avid Project files to backup
echo Hunting for Avid Project files to backup >> $logfile
find /RAIDS/RAID_1/AvidStyle -iname "Avid Projects" -print > /tmp/raid1.txt
find /RAIDS/RAID_2/AvidStyle -iname "Avid Projects" -print > /tmp/raid2.txt
find /RAIDS/RAID_3/AvidStyle -iname "Avid Projects" -print > /tmp/raid3.txt
find /RAIDS/RAID_4/AvidStyle -iname "Avid Projects" -print > /tmp/raid4.txt

# Create dated folder on mount to put these backups in to
if [ ! -d $mountpoint/$getdate ];
mkdir $mountpoint/$getdate

# Dump data
for i in cat /tmp/raid1.txt; do
echo $i
rsync -vr --size-only -R "$i" "$mountpoint/$getdate/" >> $logfile

for i in cat /tmp/raid2.txt; do
echo $i
rsync -vr --size-only -R "$i" "$mountpoint/$getdate/" >> $logfile

for i in cat /tmp/raid3.txt; do
echo $i
rsync -vr --size-only -R "$i" "$mountpoint/$getdate/" >> $logfile

for i in cat /tmp/raid4.txt; do
echo $i
rsync -vr --size-only -R "$i" "$mountpoint/$getdate/" >> $logfile

# Cleaning old data
echo Files deleted >> $logfile
find $mountpoint -mtime +3 -delete -print >> $logfile

# Let's put the log file in to the backup directory for ease as these can be too big to email:
gzip $logfile >> $logfile
cp $logfile.gz $mountpoint/$getdate/ >> $logfile

# Let's mail dem logs
/usr/local/bin/sendEmail -f [email protected] -t -u "Log file for backup" -m "Log file is in the backup directory and called $logfile.gz. It is compressed." -s -o tls=no

# End bits
umount $mountpoint

Don’t forget to create the mount point in /etc/fstab and then add this script to crontab to run at 11:59pm else you’ll get today’s date on yesterday’s file backup. Ah yeah, I forgot, you’ll need the ES root password. See your favourite ES support guys for this and see if they’ll let you in.

Leave a comment