rsync is a great tool for syncing, backing up, restoring directories with a lot of features. It comes with most Linux distributions and OS X. However, the exclude rules file has some quirks.
Suppose you want to backup all your the most crucial files (sources of the blogs, passwords databases, private documents, ssh/ssl keys, etc), scattered all around the filesystem. (It’s a good idea to backup your files!) So the basic command is:
The most interesting part for us now is --exclude-from=excludes.lst, which specifies what we actually want to copy. Its format can be looked up in the man page, we’ll check some examples.
Suppose you want get /etc/inputrc backed up, you need these lines:
123456
# include the file+ /etc/inputrc
# ignore everything else+ /etc/
- /etc/*
If you need to backup a directory (/etc/X11/xorg.conf.d/) but not everything else, the idea is similar: