Celeb Glow
general | March 31, 2026

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?

1

4 Answers

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 -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.

4

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.
5

Could try this if directories and files within are all you want backing-up. Excludes all hidden directories.

rsync -aP --exclude=.* /home/$USER/ /media/$USER/folder

10

Node modules are not mentioned, you can easily remove unwanted node module folders with the following

npm i -g npkill

then

npkill

Be careful to only section folders of your work

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy