Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to do a complicated rsync backup of a home directory on a local area network (LAN.) I need to exclude some directories but in some cases that doesn't work. Unfortunately some also have spaces (which I learned can still be backed up by escaping the slash twice.) I saw examples on various question & answer sites of how to exclude them but there was a lot of speculation and sloppy writing, so nothing there worked. I'm able to exclude directories one level in like /home/user/directory1 (can exclude directory1) but not multiple levels in like /home/user/directory1/directory2 (however I try to exclude directory2, even if it doesn't have spaces, it always gets copied.) What's the exact way to do that, or is there an easier way to list exclusions in an exclude_file.txt, --exclude-from=exclude_file.txt and what would be the format of such a file (also in the case of directories with spaces?)
My recent command was something like the following (in which /home/user/directory1/directory2/directory3 always was copied) (I did this in several steps.)
spaces (which I learned can still be backed up by escaping the slash twice.)
Well, by putting a backslash in front of the space, or quotes around the directory name.
Quote:
is there an easier way to list exclusions in an exclude_file.txt, --exclude-from=exclude_file.txt and what would be the format of such a file (also in the case of directories with spaces?)
If you have more than a handful of directories you want to exclude, a file is the better approach. One directory per line, and I don't even think quotes or backslashes are needed (I am not sure; double-check this, please).
Quote:
My recent command was something like the following (in which /home/user/directory1/directory2/directory3 always was copied) (I did this in several steps.)
If you start the rsync at /home/user/directory1, excluding directory2/directory3 has no effect indeed, because no directory with that name would be copied.
My last statement may be incorrect.
Last edited by berndbausch; 02-18-2021 at 06:38 AM.
If you start the rsync at /home/user/directory1, excluding directory2/directory3 has no effect indeed, because no directory with that name would be copied.
My last statement may be incorrect.
Yes, it is incorrect, because the example I gave was /home/user/directory1/directory2/directory3 , and in my example command, everything in directory1 is copied (recurses the directories) including directory2 then directory3... which I want to exclude.
You are right, --exclude=directory2/directory3 should work. And you know what - I tried it, and it did work. This is my directory structure on an Odroid SBC running Ubuntu 16:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.