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

Empty lines in exclude-file result in empty snapshot #915

Closed
Gjum opened this issue Apr 16, 2017 · 5 comments
Closed

Empty lines in exclude-file result in empty snapshot #915

Gjum opened this issue Apr 16, 2017 · 5 comments

Comments

@Gjum
Copy link

Gjum commented Apr 16, 2017

Output of restic version

restic 0.5.0 (356099d)
compiled with go1.8.1 on linux/amd64

Expected behavior

my-exclude:

first-line

third-line

command:

restic -r /repo backup /data --exclude-file my-exclude

I expect this to back up all of /data except first-line and third-line.

This is of course a simplified example, my real exclude files are much bigger and their readability benefits from empty lines.

Actual behavior

Because the file contains a newline, no files in /data get scanned:

enter password for repository: 
scan [/data]
scanned 0 directories, 0 files in 0:00
[0:00]   0B/s  0B / 0B  0 / 0 items  0 errors  ETA 0:00 
duration: 0:00, 0.00MiB/s
Fatal: no files/dirs saved, refusing to create empty snapshot

A quick search revealed this (possibly) relevant part of the code, where only comment lines are discarded, but empty lines get added as exclude patterns.

Removing the newline or replacing it with a comment results in the expected behavior.

Steps to reproduce the behavior

See Expected behavior.

@Gjum
Copy link
Author

Gjum commented Apr 16, 2017

Also somewhat related, as far as I can tell multiple usages of --exclue-file are not supported for backup, instead the second usage overrides the first.

I couldn't find a Github issue for that but that probably is already tracked somewhere. Just thought I'd mention that because it's also somewhat unexpected behavior relating to exclude files, if you think it's reasonable I can open another issue for this specific problem.

A quick workaround would be to use --exclude-file <(cat first.exc second.exc), but that still leaves the unexpected overriding behavior.

@fd0
Copy link
Member

fd0 commented Apr 16, 2017

Hey, thanks a lot for the report and taking the time to debug this! I'll have a look.

@fd0
Copy link
Member

fd0 commented Apr 16, 2017

Could you please check if the code in #916 (branch fix-915) solves the bug you reported.

@Gjum
Copy link
Author

Gjum commented Apr 16, 2017

Everything works perfectly now, both using empty lines and specifying multiple exclude files. Thanks for the quick response, that means a lot.

Keeping this open until the PR is merged.

@fd0
Copy link
Member

fd0 commented Apr 17, 2017

yep, I'll close it when I merge the PR

@fd0 fd0 closed this as completed in #916 Apr 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants