{"action":"created","issue":{"url":"https://api.github.com/repos/restic/restic/issues/233","labels_url":"https://api.github.com/repos/restic/restic/issues/233/labels{/name}","comments_url":"https://api.github.com/repos/restic/restic/issues/233/comments","events_url":"https://api.github.com/repos/restic/restic/issues/233/events","html_url":"https://github.com/restic/restic/issues/233","id":95845379,"number":233,"title":"Allow mixing include and exclude patterns for backup and restore","user":{"login":"fd0","id":123276,"avatar_url":"https://avatars.githubusercontent.com/u/123276?v=3","gravatar_id":"","url":"https://api.github.com/users/fd0","html_url":"https://github.com/fd0","followers_url":"https://api.github.com/users/fd0/followers","following_url":"https://api.github.com/users/fd0/following{/other_user}","gists_url":"https://api.github.com/users/fd0/gists{/gist_id}","starred_url":"https://api.github.com/users/fd0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fd0/subscriptions","organizations_url":"https://api.github.com/users/fd0/orgs","repos_url":"https://api.github.com/users/fd0/repos","events_url":"https://api.github.com/users/fd0/events{/privacy}","received_events_url":"https://api.github.com/users/fd0/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/restic/restic/labels/enhancement","name":"enhancement","color":"bfe5bf"},{"url":"https://api.github.com/repos/restic/restic/labels/feedback%20needed","name":"feedback needed","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-18T17:59:57Z","updated_at":"2015-07-18T18:12:03Z","closed_at":null,"body":"This is a followup issue for #226. Up to now it is only possible to specify exclude patterns for backup and restore.\r\n\r\nThere are uses cases that aren't covered, for example: A user would like to backup her home directory at `/home/user`, excluding anything from the directory `work` except C source files.\r\n\r\nAre there any other uses I haven't thought of?\r\n\r\nImplementation/User Interface: Allow specifying both `--include` and `--exclude` patterns on the command line, which fill a common list (order does matter here). For each dir/file, check all patterns in the list. The action (exclude or include) of the last mattching pattern wins. The default action (which will also be used if neither include nor exclude patterns are specified) is \"include\".\r\n\r\nThis already contains a corner case: Should restic walk `/home/user/work` at all?\r\n\r\nI think it should not. Instead, if this is a desirable behaviour, require the user to add a more specific pattern to signal that the excluded directory should also be walked, e.g. `restic backup --exclude /home/user/work --include /home/user/work/**/*c. /home/user`.\r\n\r\nA better user interface would be to allow specifying a file to read the patterns from (`--pattern-file` or something like that). In this file, all lines starting with `#` are comments, empty lines ignored, all other lines must start with either `+` (include) or `-` (exclude) following a space character and a pattern. For the use case above a filter file would look like this:\r\n\r\n    # filter out everything from work, but include c source code files\r\n    - /home/user/work\r\n    + /home/user/work/**/*.c\r\n\r\nThis issue can be closed once a definitive solution for having both include and exclude patterns is implemented.\r\n"},"comment":{"url":"https://api.github.com/repos/restic/restic/issues/comments/122573723","html_url":"https://github.com/restic/restic/issues/233#issuecomment-122573723","issue_url":"https://api.github.com/repos/restic/restic/issues/233","id":122573723,"user":{"login":"fw42","id":2072686,"avatar_url":"https://avatars.githubusercontent.com/u/2072686?v=3","gravatar_id":"","url":"https://api.github.com/users/fw42","html_url":"https://github.com/fw42","followers_url":"https://api.github.com/users/fw42/followers","following_url":"https://api.github.com/users/fw42/following{/other_user}","gists_url":"https://api.github.com/users/fw42/gists{/gist_id}","starred_url":"https://api.github.com/users/fw42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fw42/subscriptions","organizations_url":"https://api.github.com/users/fw42/orgs","repos_url":"https://api.github.com/users/fw42/repos","events_url":"https://api.github.com/users/fw42/events{/privacy}","received_events_url":"https://api.github.com/users/fw42/received_events","type":"User","site_admin":false},"created_at":"2015-07-18T18:12:03Z","updated_at":"2015-07-18T18:12:03Z","body":"Another possibility would be to read an exact list of files to backup from a file (or from stdin). Then people could just use whatever tools they want (find, grep, etc.) to build their list and \"pipe\" that list to restic."}}