My Beautiful Remote Backup Script

I spent a large part of last week writing a really cool off-site automated backup script.  Coding looks easy sometimes but a single line can often take me hours of research and trial and error.  It’s finished, and it’s beautiful.  Here’s what it does:

1) From a list of directories  you want to back up, the script takes each one in turn.  First it creates a disk image (.dmg) of the entire folder using hdiutil.  This image is stored in a folder the script creates and is named according to the directory it is backing up.

2) To avoid file size limitations on foreign servers, the disk image is segmented into 1GB chunks.  Each part is encrypted.  This was also done with hdiutil.

3) The entire folder (now in encrypted segments) is queued for upload via FTP using ncftpput, a very handy script tool.

4) To avoid space limitations on the local drive, the script waits until the entire directory is uploaded.  It then deletes the disk images and moves on to the next folder in the list.

It was working flawlessly, although FTP’ing many gigabytes takes days when your upload speed is around 300 KB/s.  I also throttled the bandwidth of ncftpput to 200 so I could do other stuff on my connection while it ran in the background.

The problem came when my host shut my entire account down.  Apparently they don’t like you using their space for anything other than web-related files.  A pity, as I have terabytes of space available to me.

So I’m left with a beautiful, functional remote backup script with no off-site backups 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *