Step 1.) Know where the usb drive is mounted. I used gparted to format mine with one big ext3 partition named “LinuxBackup” so it gets automounted at /media/LinuxBackup (in Ubuntu).
Step 2.) Create a folder on your usb drive where you want the backup to go.
Step 3.) Install the required program: rsync
Ready to go:
$ rsync -rupogt –delete /SOURCE/DATA/DIRECTORY/ /media/DRIVENAME/SUBFOLDER
Note: the SUBFOLDER on the drive must exist. Also, if I remember correctly there is some significance to there being a following “/” at the end of the source folder name. Your own needs may vary from mine, so look up the rsync options and adjust accordingly. For example, I use the –delete option, which deletes all files and folders on the destination which do not exist in the source. If you don’t use this option, and you rename or move a directory on your computer, you will end up with two copies of the same files, one of them under the old name! BEWARE: the –delete option will also destroy previously backed-up files that you have since deleted on your source computer, and they will be lost forever. Always think before doing this. There is little chance of recovering deleted files from the destination. This is especially pertinent when going the other way, from drive-to-computer. If the destination computer folder contains newer files that aren’t on the usb drive source, the –delete option will destroy them!
For my system, I have a usb drive named LinuxBackup, and two computers: one at work, and one at home. When I’m done working at home I put in the usb drive and run
$ rsync -rupogt –delete ~/Documents/ /media/LinuxBackup/Documents
to put the newest copy of my Documents folder on my usb drive. Then, when I get to work, I load the newest copy of the Documents onto my work computer by running
$ rsync -rupogt –delete /media/LinuxBackup/Documents/ ~/Documents
This would be much easier if I wasn’t firewalled on both ends, since rsync is designed to do this over the internet using ssh. Oh well, the usb drive works well enough. And I have three copies of the data instead of two, which is 50% safer, right?