In this post, I’d share my way to ignore node_modules
folders from backing up with Deja-Dep(Backups).
Motivation
I’m using Deja-Dup (Backups) in my Ubuntu 22.04 to backup files. While backing up, many directories and sub-directories named “node_modules” are backed up. Their sizes are sometimes up to 500MB for one directory. And they are easily downloadable again. So I wanted to exclude these files.
Setting
Ignore setting is available in Deja Dup, but the problem is that node_modules
directories are created and destroyed so often. Therefore, I needed general settings.
(This does not work) First, I set many layers of directories on the Backups setting using dconf. This did not work. I tried to set it using asterisks, like */*/node_modules
, which did not work.
(This works) Finally, I reached the way to put .deja-dup-ignore
empty-file in each node_modules/
directory.
find ~/ -name node_modules -prune -exec touch {}/.deja-dup-ignore \;
The command
- finds all the directories with
node_modules/
(-prune
stops searching the tree branch when finds firstnode_modules/
) touch
to create.deja-dup-ignore
file in each found directory
CRON daily command
I use the CRON schedule to run this command every day. By this, I don’t need to care about which directories are set or not for my weekly backups.
5 0 * * * find ~/ -name node_modules -prune -exec touch {}/.deja-dup-ignore \;
Summary
By regularly creating the .deja-dup-ignore
file, we can avoid backing up unwanted node_modules
directories.
Note
You can find all of .deja-dup-ignore
using this command.
find ~/ -name .deja-dup-ignore