Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable --include-from flag of rsync #21

Merged
merged 3 commits into from
Oct 24, 2021

Conversation

deeperlearner
Copy link
Contributor

@deeperlearner deeperlearner commented Jul 18, 2021

Sorry for recreating PR, I change the branch name.

I add the --include-from so that rsync can include specified pattern.

Thanks.

deeperlearner added 2 commits July 17, 2021 23:08
@pedroetb
Copy link
Owner

Hi, I'm including new features to release a new minor version, and I think your pull request can be included (no breaking changes). But after reviewing about this, I found: https://newbedev.com/rsync-include-from-vs-exclude-from-what-is-the-actual-difference

Rsync builds an ordered list of include/exclude options as specified on the command line. Rsync checks each file and directory name against each exclude/include pattern in turn. The first matching pattern is acted on. If it is an exclude pattern, then that file is skipped. If it is an include pattern then that filename is not skipped. If no matching include/exclude pattern is found then the filename is not skipped.

So, if a filename does not match any include or exclude pattern, it will be included in backup anyways (no breaking changes).

In addition, it seems to match only first include/exclude pattern, so I think --include-from should be before --exclude-from in rsync command to take precedence. Do you agree @deeperlearner?

Thanks for your time!

@pedroetb pedroetb self-assigned this Oct 24, 2021
@deeperlearner
Copy link
Contributor Author

Hi,
I'm not sure about the effect of changing the order of --include-from and --exclude-from.
Take my case for example:
exclude.txt:

.tmp.drivedownload/
__pycache__/
desktop.ini

include.txt:

+ Folder*/***
+ Folder\ with\ space/***
- *

In my use case, the plus folders in include.txt is top folders inside the rsync source file (${src}/).
I didn't consider and check more general cases.
I just want to use include.txt to select main backup folders inside ${src}/.

Thanks for reviewing my request!

@pedroetb
Copy link
Owner

Ok, I didn't know you can use prefixes ('+', '-'...) into include/exclude files! More info at: https://man7.org/linux/man-pages/man1/rsync.1.html#FILTER_RULES

Using include file that way, you might go without exclude file, indeed. But I also prefer using 2 different files, with support for prefixes and no-prefixes.

@deeperlearner I think it will work both ways (include-from before or after exclude-from) in your use case. I'm going to merge and resolve conflicts with your pull-request, and put --include-from before. Let me know if it causes any trouble when new version is released, please.

Thanks for your contribution!

@pedroetb pedroetb merged commit 9e074d4 into pedroetb:master Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants