Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
my system is running rsync version 3.0.7. i want to use it to synchronize files and folders in another directory on the same system. however, i want to exclude particular files and/or folders when i execute the command. i'm not familiar with rsync and i'd like someone to please verify the syntax for me. below is an example of what i want to do:
I'd rather not assume I know exactly what it is you want to do, but here are some tips:
1) The -a flag might be of use to you to make sure you sync pretty much everything.
2) The order of the --exclude's matters.
3) There is a difference between hiding something and excluding something. See the more general --filter option.
4) Use the -i flag so you can see exactly what is going on. I usually have a -in at the end of my rsync command. That way I can check what's happening first, then easily run the command again and remove the n so it can run for real.
5) If you want a true sync, you may want to look at the --delete flag. And to be safe, look into the --backup flag (to be used with --delete).
6) A trailing slash matters for the source directory! (It doesn't matter for the destination.)
Ok, so looking at your command, there is one thing that I'm sure you are confused about.
Your source is /path/to/source/files and, for example, your first exclude is /path/to/source/files/dir1. This is actually excluding /path/to/source/files/path/to/source/files/dir1. The filter rules are relative to the source. So what you want is one of the following:
1) --exclude=dir1 # this will exclude any file or directory named dir1, anywhere below /path/to/source/files
2) --exclude=dir1/ # this will exclude ONLY directories named dir1, anywhere below /path/to/source/files
3) --exclude=/dir1 # this will exclude TTHE file/directory dir1 if it exists at the root of your transfer, so /path/to/source/files/dir1, and only that
4) --exclude=/dir1/ # similar to the above, but only a directory
Can you please elaborate? For my backups, I'm thinking about switching to an exclude *file* (high numbers of exclude arguments quickly become unwieldy in the --exclude= syntax).
Does order apply here too? I.e. Do I put "wildcards" (folders and/or files occuring anywhere) first or last in the list?
Thx.
Last edited by roeland.de.windt; 03-02-2010 at 05:50 PM.
Reason: Cosmetics
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.