{"action":"created","issue":{"url":"https://api.github.com/repos/restic/restic/issues/226","labels_url":"https://api.github.com/repos/restic/restic/issues/226/labels{/name}","comments_url":"https://api.github.com/repos/restic/restic/issues/226/comments","events_url":"https://api.github.com/repos/restic/restic/issues/226/events","html_url":"https://github.com/restic/restic/issues/226","id":94109663,"number":226,"title":"User Interface: Ignoring files/dirs 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"},{"url":"https://api.github.com/repos/restic/restic/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-07-09T17:38:14Z","updated_at":"2015-07-10T14:13:18Z","closed_at":null,"body":"I'd like to propose a user interface for selecting and ignoring files to backup and restore (this connects to #86):\r\n\r\nAdd `--exclude` and `--include` to `backup` and `restore`, both parameters can be added multiple times and each specifies a pattern.\r\n\r\n * If neither `--exclude` nor `--include` is specified, all files are backed up or restored.\r\n * If only `--include` is specified (at least once), only the items that match the given pattern are backed up or restored.\r\n * If only `--exclude` is specified (at least once), all items except those that match the given pattern are backed up or restored.\r\n * If both `--exclude` and `--include` are specified, only those items are backed up that either\r\n   * don't match any exclude pattern\r\n   * match an exclude pattern and at least one include pattern\r\n\r\nAs for the pattern, I'd like to implement something that is easy to use. Some examples:\r\n\r\n * `/proc` matches all items below `/proc`, e.g. `/proc/kcore`\r\n * `foo/*` matches all items in a subdirectory of a directory called `foo`, e.g. `/home/user/foo/test.txt`\r\n * `foo/**/bar*/*.c` matches all items with the extension `.c` in a directory whose name begins with `bar` that somewhere has a parent directory called `foo`.\r\n\r\nSo, the rules are roughly:\r\n * If the pattern starts with a slash, the following name is meant absolute\r\n * If the pattern matches a directory, it matches all subdirs/items below, e.g. `/proc` is the same as `/proc/*`\r\n * Similar to shell globbing, `*` matches everything\r\n\r\nUsage examples:\r\n\r\n * Backup everything except `/proc`,`/sys` and all vim swap files: `restic backup --exclude /proc --exclude /sys --exclude \"*.swp\" /`\r\n * Backup only c source code files ignoring everything else: `restic backup --include \"*.c\" /home/user`\r\n * 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`\r\n\r\nI think this can be implemented fairly easy by using `filepath.Match`.\r\n\r\nWhat do you think about this approach? Are you aware of any use cases that aren't covered?\r\n\r\n@restic/devs, @ceh, @rubenv, @howeyc, @rakoo\r\n"},"comment":{"url":"https://api.github.com/repos/restic/restic/issues/comments/120418852","html_url":"https://github.com/restic/restic/issues/226#issuecomment-120418852","issue_url":"https://api.github.com/repos/restic/restic/issues/226","id":120418852,"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},"created_at":"2015-07-10T14:13:17Z","updated_at":"2015-07-10T14:13:17Z","body":"@rawtaz I disagree, restic should do as it is told, so `restic backup .` should create a backup of the current directory and not try to be smarter as the user by filtering `.` as an argument. I'm not so sure about filtering `..`, I think this is used only seldomly.\r\n\r\nBash can be configured to include items starting with a dot in the regular expansion of `*` by setting an option, see http://unix.stackexchange.com/questions/1168/how-to-glob-every-hidden-file-except-current-and-parent-directory"}}