• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Question Rsync exclude patterns – required to use wildcards with folder names?

King555

Regular Pleskian
Just a short question, maybe someone has an answer for me. I backup my server using "Rsync".

Why does this command exclude nothing:

Code:
rsync -a  --exclude={"/boot/lost+found/","/dev/"} -e 'ssh -p23' / [email protected]:/backup/

while this excludes the files within the two folders as desired?

Code:
rsync -a  --exclude={"/boot/lost+found/*","/dev/*"} -e 'ssh -p23' / [email protected]:/backup/

(wildcard "*" two times)

Actually I wanted to exclude the whole directories, not only the files. But it did not work. Rsync completely ignored my exclude patterns.
 
If I have to guess it's probably because of the trailing slash since the trailing slash wouldn't match the pattern for the detection if I'm reading up on rsync correctly. Might want to drop off the slash and check so it looks something like this:

Bash:
rsync -a  --exclude={"/boot/lost+found","/dev"} -e 'ssh -p23' / [email protected]:/backup/
 
Thanks for your reply. It sounded logical in the first place, but under "Include/Exclude Pattern Rules" the rsync man page says:
"if the pattern ends with a / then it will only match a directory, not a regular file, symlink, or device."

When a directory is excluded, shouldn't all files within it also be excluded?

And several days ago I did a transfer from an SMB mount to the rsync server and used "--exclude=/backup1/ --exclude=/backup2/" and these folders where excluded completely (the folder and the files).

I will test it without the trailing slash and with several exclude params instead of one with curly braces. But it's still strange to me.
 
Now I did some tests. First of all I found out that the curly braces version only works with at least two entries. Not relevant for my case, but if someone wanted to know. So
Code:
--exclude={"/exclude1/","/exclude2/"}
works and
Code:
--exclude={"/exclude1/"}
does not (nothing is excluded).

Every combination of slashes worked now:
Code:
--exclude={"/exclude1/","/exclude2/"}
--exclude={"/exclude1","/exclude2"}
--exclude={"exclude1/","exclude2/"}
--exclude={"exclude1","exclude2"}
--exclude={"/exclude1/*","/exclude2/*"}
--exclude={"exclude1/*","exclude2/*"}
Which is strange, of course, because before the first version did not work. I guess the reason must be that I now backed up "/test/" instead of "/". I can't do many tests with "/", because it takes too long.

I think leaving the trailing slash away is not a good way anyway, because then also files with those names would be excluded.

I will do further testing to find out what's wrong with my initial approach.
 
Back
Top