Thursday, 11 October 2012

Using rsync to back up a home directory

Having a laptop that's on it's last legs, I'm looking at backing up my home directory.

However, I don't want to backup all the cruft that has accumulated there.

Rsync has a useful option to exclude a list of named directories: --exclude-from file.txt, where file.txt contains the list of files and directories to exclude.

So this is the procedure:

1. Perform a dry-run to investigate which cruft should be removed (-n indicates a dry-run):

e.g., rsync -avzn --exclude-from exclude.txt $source_dir $destination_dir

2. Add crufty patterns to exclude.txt:

3. Repeat until satisfied

4. Run actual rsync, e.g. rsync -az --exclude-from exclude-txt $source_dir $destination_dir


% cat exclude.txt