You are not logged in.

#1 2022-07-23 13:20:15

difri84
Member
Registered: 2021-12-09
Posts: 78

rsync to backup dot files [SOLVED]

i made an alias to sync my dot files which is:

sudo rsync -avh --exclude={'.Trash-1000','.cache'}  ~/.[^.]* /mnt/timeshift/dotfiles/ --delete

reading the documentation i understand that since the source is expressed with a final * every file in the parent directory is considered as a source, then the --delete flag only works on subdirectories.

the result i'm looking for is a rsync command that copy every dotfile in my home directory and every dotfolder and relative subfolders with the -- delete flag working on every file synced. Any advice?

thank you!

Last edited by difri84 (2022-07-30 00:25:33)

Offline

#2 2022-07-26 06:35:58

Bevan
Member
Registered: 2009-09-08
Posts: 99

Re: rsync to backup dot files [SOLVED]

You could try:

rsync -avh --exclude '.Trash-1000' --exclude '.cache' --include '/.*' --exclude '/*' --delete ~/ /mnt/timeshift/dotfiles/

That way you operate on entire directories and the selection of dot file happens solely via rsync's include/exclude. This command will however not delete explicitly excluded data from the target, so if some non-dot-file got synced (or .Trash-1000 or .cache), they will stay.

I only tried this very briefly, so make sure with a dry-run that this command does what you want it to do.

Offline

#3 2022-07-29 22:41:11

difri84
Member
Registered: 2021-12-09
Posts: 78

Re: rsync to backup dot files [SOLVED]

this works as intended

rsync -avh --exclude={'.local/share/Trash','.Trash-1000','.cache','.config/whatsapp-nativefier*','/[^.]*'} ~/ /mnt/timeshift/dotfiles/ --delete

the key is the last exclude parameter

/[^.]*

which means any file not starting with a dot in the main directory (thanks to the initial /, otherwise it would have excluded any non dot file in subfolders too), apparently the --include section is not needed at all.

modify this according to your needs!
thanks for the idea!!!

Last edited by difri84 (2022-07-30 00:23:52)

Offline

Board footer

Powered by FluxBB