Backup your home directory with rsync and skip useless folders
You can easyly backup your home folder on an external harddrive with
rsync -a --exclude=.cache --progress /home/$USER /media/linuxbackup/home/$USER
I excluded the .cache folder cause I think I will never need it when I have to re-install from this backup.
I found this list of all folders that I could exclude in a normal backup here:
What files and directories can be excluded from a backup of the home directory?
I created a list of this answer that contains some coments in this form:
#These directories may be excluded:
.gvfs # contains mounted file systems?
.local/share/gvfs-metadata
.Private # contains the actual encrypted home directory
.dbus # session-specific
.cache
.Trash # do I need to say more?
.local/share/Trash
.cddb # cached info about audio CDs
.aptitude # cached packages lists
#Flash-specific:
.adobe # Cache for flash, maybe others?
.macromedia # except for Flash persistence, there is no reason to keep this
#Files:
.xsession-errors # contains errors from the current graphical session
.recently-used # recently used files
.recently-used.xbel
.thumbnails
Here is the full list at gist
How can I add this list to my rsync command?
Solution 1:
The exclude list may only contain filenames, foldernames and lines starting with #
. A comment behind the foldername is not allowed. I created a Git repository with all known files and folders that are superfluous:
Download this ignorelist to /var/tmp/ignorelist
wget https://raw.githubusercontent.com/rubo77/rsync-homedir-excludes/master/rsync-homedir-excludes.txt -O /var/tmp/ignorelist
Then start the rsync with
rsync -aP --exclude-from=/var/tmp/ignorelist /home/$USER/ /media/$USER/linuxbackup/home/
Note:
In the ignorelist there is a commented section at the start with folders, that are probably not worth a backup either. Uncomment those, you don't need.
Solution 2:
From man rsync
:
--exclude-from=FILE read exclude patterns from FILE
This option is related to the --exclude option, but it specifies
a FILE that contains exclude patterns (one per line). Blank
lines in the file and lines starting with ’;’ or ’#’ are
ignored. If FILE is -, the list will be read from standard
input.