Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
#!/bin/sh
# directory to backup
BDIR=/home/$USER
# excludes file - this contains a wildcard pattern per line of files to exclude
EXCLUDES=exclude.txt
OPTS="-a -r -v --exclude-from=$EXCLUDES"
# the name of the backup machine
BACKUPDIR=/tmp/test_rsync
# now the actual transfer
rsync $OPTS $BDIR $BACKUPDIR
i try to exclude some folde and all sub-directory...
in my exclude.txt i have
+ /home/collinm/mp3
+ /home/collinm/Download
when i run the script, rsync copy all file .... it copy mp3 and Download folder..... but i don't want that....
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
I don't have the computer on which I have installed rsync at hand, so just two wild guesses:
1. "+" in front of a rule usually means that the path is INcluded. Now I don't know if "+" in an EXclude file means exclude, or include. Intuitively I would say that in an exclude file reverse logic is true. However, just try the path without "+" and preceeded with "-"
2. When rsync descends into directories, the rule must still be true. That means that the path /home/collinm/mp3/hardrock does NOT match the rule /home/collinm/mp3. You would have to specify the rule as /home/collinm/mp3/* Only then every subdir matches your rule.
An "exclude file" defaults to the "-" operation if it is not specified whereas an "include file" defaults to "+". However, you can make an exclude file behave like an include file by prefacing the lines with a "+". This is exactly what you did. The converse is also true for an include file with "-" lines in it (this would behave like an exclude file).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.