-
Notifications
You must be signed in to change notification settings - Fork 1.7k
User Interface: Ignoring files/dirs for backup and restore? #226
Copy link
Copy link
Closed
Labels
state: need feedbackwaiting for feedback, e.g. from the submitterwaiting for feedback, e.g. from the submittertype: feature enhancementimproving existing featuresimproving existing featurestype: question/problemusage questions or problem reportsusage questions or problem reports
Description
I'd like to propose a user interface for selecting and ignoring files to backup and restore (this connects to #86):
Add --exclude and --include to backup and restore, both parameters can be added multiple times and each specifies a pattern.
- If neither
--excludenor--includeis specified, all files are backed up or restored. - If only
--includeis specified (at least once), only the items that match the given pattern are backed up or restored. - If only
--excludeis specified (at least once), all items except those that match the given pattern are backed up or restored. - If both
--excludeand--includeare specified, only those items are backed up that either- don't match any exclude pattern
- match an exclude pattern and at least one include pattern
As for the pattern, I'd like to implement something that is easy to use. Some examples:
/procmatches all items below/proc, e.g./proc/kcorefoo/*matches all items in a subdirectory of a directory calledfoo, e.g./home/user/foo/test.txtfoo/**/bar*/*.cmatches all items with the extension.cin a directory whose name begins withbarthat somewhere has a parent directory calledfoo.
So, the rules are roughly:
- If the pattern starts with a slash, the following name is meant absolute
- If the pattern matches a directory, it matches all subdirs/items below, e.g.
/procis the same as/proc/* - Similar to shell globbing,
*matches everything
Usage examples:
- Backup everything except
/proc,/sysand all vim swap files:restic backup --exclude /proc --exclude /sys --exclude "*.swp" / - Backup only c source code files ignoring everything else:
restic backup --include "*.c" /home/user - Backup the user's home directory, excluding everything except c source code from the directory
work:restic backup --exclude /home/user/work --include "*.c" /home/user
I think this can be implemented fairly easy by using filepath.Match.
What do you think about this approach? Are you aware of any use cases that aren't covered?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
state: need feedbackwaiting for feedback, e.g. from the submitterwaiting for feedback, e.g. from the submittertype: feature enhancementimproving existing featuresimproving existing featurestype: question/problemusage questions or problem reportsusage questions or problem reports