[FoRK] Backing Up OS X via SSH/RSync

Ian Andrew Bell < hello at ianbell.com > on > Fri Nov 24 13:15:31 PST 2006

This may not be rocket science to most of you but is potentially  
quite useful:

Recently I lost a bunch of data from a MacBook Pro that spun off of  
the corner of my sofa onto my hardwood floor.  Ouch.  My last backup  
had been about a month earlier so I lost some pretty important stuff  
I was working on at the time and had to spend hours mungeing the  
drive with various data recovery tools.

I decided once and for all to solve my backup problems.  Any backup  
strategy that I would employ, fundamentally, would have to adapt to  
the fact that I am lazy and that I am a data packrat.  Here's what I  
did, and this will work for anyone with OS X or linux, half an hour,  
and a unix host somewhere that has RSYNC installed properly.

First, I created a special account on my DreamHost box called  
"macbookbackup" and gave it shell/ssh access.  To create the key and  
place it on the server I did the following:

 From the Command Line (on my machine):

ssh-keygen -d
# hit enter three times
ssh macbookbackup at hostname.dreamhost.com 'test -d .ssh || mkdir -m  
0700 .ssh ; cat >> .ssh/authorized_keys && chmod 0600 .ssh/*' <  
~/.ssh/id_dsa.pub
# enter password

That sets up key-based authentication so that when sshing to the host  
in the future, it won't need my password.

I then created a script on my local machine to back up the folders  
using rsync, one line per folder to backup.  I find rsync  
extraordinarily complex to do actual syncing but when it comes to  
just pumping data out the back door on a regular basis, it's super- 
duper easy.

mkdir ~/Scripts
cat > ~/Scripts/sync-all
rsync -a ~/Documents macbookbackup at hostname.dreamhost.com:~/Backup/
rsync -a ~/Library macbookbackup at hostname.dreamhost.com:~/Backup/
rsync -a ~/Projects macbookbackup at hostname.dreamhost.com:~/Backup/
rsync -a ~/Movies macbookbackup at hostname.dreamhost.com:~/Backup/
rsync -a ~/Music macbookbackup at hostname.dreamhost.com:~/Backup/
^D   # (that's a control-D)
chmod a+x ~/Scripts/sync-all

I then downloaded LingOn, which lets you schedule and manage the  
rsync process via a GUI:

http://lingon.sourceforge.net/

I've included some screenshots of the config process (this will rsync  
my Documents folder up to my Dreamhost acct every 10hrs, and do it as  
low priority so it doesn't impact other things) but you can season to  
taste.

Enjoy!  Hope this is useful.

-Ian.




____
http://www.linkedin.com/in/ianbell



More information about the FoRK mailing list