Wednesday, September 28, 2005

Backing up your stuff to a Linux server

Backing up your data to DVD or another hard disk or computer is very important but people really don't do it. If you own a laptop, this is even more important as your laptop can be stolen and it's not hard to get data off your laptop without a password or removing the hard drive (they just boot your laptop and hold the 't' key down and connect a firewire cable. So, make sure you use those encrypted disk images)!

In this example, I'm backing up to a Linux box. This can easily be a box running FreeBSD, Mac OS X or any other OS with a working installation of rsync and SSH.

First, you create a SSH public key for your local computer (the one you're backing up) using the following command:

ssh-keygen -t dsa

Then you copy the id_dsa.pub file to the ~/.ssh/ directory on your account on the remote computer. If you don't have a .ssh directory, first create it: mkdir ~/.ssh; chmod 0700 ~/.ssh

Now, copy your id_dsa.pub file over:
scp ~/.ssh/id_dsa.pub user@remotebox:newkey

Log into your account on the remote box and insert the key into your authorized_keys file.

cat ~/newkey >> ~/.ssh/authorized_keys

You should be able to log into your account for your local machine without a password.

Create two directories on the remote machine:
mkdir ~/backup
mkdir ~/apps

Now, on your local machine you can begin using rsync with ssh. The following command backs up everything in my home (~) folder except the Trash and Cache in Safari. When ever I delete something in my home directory and sync my laptop with the remote computer, the copy of that file is removed there also.

rsync -e ssh -avz --delete --exclude=".Trash*" --exclude="Library/Caches/Safari/" ~ user@remotebox:backup

The next command will require your local machine's admin password so that you can access all the files in the Application folder and then the password of the account on the remote machine.

sudo rsync -e ssh -avz --delete /Applications/ user@remotebox:apps

That's it. Be sure to do it regularly.

2 Comments:

At 3:44 PM , Anonymous Anonymous said...

hey there - im from australia - found your site and thought it was great how you explained it.

keep up the good work. hope you enjoy your new PB.
cheers
A.

 
At 3:46 PM , Blogger aussie aubs said...

oops - heres me :)

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home