I'm trying to perform complex rsync include/excludes to backup only the following within the /home/x dir:

  • Recursively all files/dirs in Documents
  • Recursively all files/dirs in .PlayOnLinux/wineprefix/evernote/drive_c/users/x/Local Settings/Application Data/Evernote/Evernote/Databases/

I understand that one needs to include all of the parent directories down to the desired directory before using the exclude rule. However, as seen in my rule file below, this is very inefficient to setup and completely clutters up the rule file making it difficult to read:

+ Documents
+ Documents/**
+ .PlayOnLinux
+ .PlayOnLinux/wineprefix
+ .PlayOnLinux/wineprefix/evernote
+ .PlayOnLinux/wineprefix/evernote/drive_c
+ .PlayOnLinux/wineprefix/evernote/drive_c/users
+ .PlayOnLinux/wineprefix/evernote/drive_c/users/x
+ .PlayOnLinux/wineprefix/evernote/drive_c/users/x/Local Settings
+ .PlayOnLinux/wineprefix/evernote/drive_c/users/x/Local Settings/Application Data
+ .PlayOnLinux/wineprefix/evernote/drive_c/users/x/Local Settings/Application Data/Evernote
+ .PlayOnLinux/wineprefix/evernote/drive_c/users/x/Local Settings/Application Data/Evernote/Evernote
+ .PlayOnLinux/wineprefix/evernote/drive_c/users/x/Local Settings/Application Data/Evernote/Evernote/Databases
+ .PlayOnLinux/wineprefix/evernote/drive_c/users/x/Local Settings/Application Data/Evernote/Evernote/Databases/**
- *

Everything here works as intended. However, is there a better, more efficient way than this to achieve rsync backup of the contents of only certain sub-dirs in long paths whilst preserving the original directory structure?

EDIT I have discovered three asterisks can be employed to include sub-dir content one level deep without separately defining the sub-dir name to include (e.g. + Documents/*** works to replace the two relevant lines in the above rules). However, this does not appear to work for sub-dirs more than one level deep, which is the case in this question.

rules="+ /Documents/**
+ /.Play...bases/**
+ */
- *"

echo $rules | rsync -rm -f ". -" --delete-excluded /home/x /dest

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.