rustic-rs / rustic

rustic - fast, encrypted, and deduplicated backups powered by Rust
https://rustic.cli.rs
Apache License 2.0
2k stars 72 forks source link

.gitignore vs iglob-file priority #945

Open kuyagic opened 1 year ago

kuyagic commented 1 year ago

I have the following iglob-file

!*.pfx
!*.log

and I backup the .ssh folder with the following .gitignore file in it

netbird-200:~/.ssh# cat .gitignore
!*.pfx
*.old
netbird-200:~/.ssh#

I prefer the pfx file in .ssh folder will be backed up , but it is not being backup.

Here is the full log

netbird-200:~/.ssh# rustic backup -n --log-level debug > /dev/stdout  2> /dev/stdout  | grep ignoring
[DEBUG] (27) ignore::walk: ignoring /root/.ash_history: Ignore(IgnoreMatch(Override(Glob(Matched(Glob { from: None, original: "!**/.*_history",
 actual: "**/.*_history", is_whitelist: true, is_only_dir: false })))))
[DEBUG] (27) ignore::walk: ignoring /root/.cache: Ignore(IgnoreMatch(Override(Glob(Matched(Glob { from: None, original: "!**/.cache", actual: "
**/.cache", is_whitelist: true, is_only_dir: false })))))
[DEBUG] (27) ignore::walk: ignoring /root/.gnupg/S.dirmngr: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("/root/.gnupg/.gitignore"), original
: "S.*", actual: "**/S.*", is_whitelist: false, is_only_dir: false })))
[DEBUG] (27) ignore::walk: ignoring /root/.gnupg/S.gpg-agent: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("/root/.gnupg/.gitignore"), origin
al: "S.*", actual: "**/S.*", is_whitelist: false, is_only_dir: false })))
[DEBUG] (27) ignore::walk: ignoring /root/.gnupg/S.gpg-agent.browser: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("/root/.gnupg/.gitignore")
, original: "S.*", actual: "**/S.*", is_whitelist: false, is_only_dir: false })))
[DEBUG] (27) ignore::walk: ignoring /root/.gnupg/S.gpg-agent.extra: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("/root/.gnupg/.gitignore"),
original: "S.*", actual: "**/S.*", is_whitelist: false, is_only_dir: false })))
[DEBUG] (27) ignore::walk: ignoring /root/.gnupg/S.gpg-agent.ssh: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("/root/.gnupg/.gitignore"), or
iginal: "S.*", actual: "**/S.*", is_whitelist: false, is_only_dir: false })))
[DEBUG] (27) ignore::walk: ignoring /root/.gnupg/S.keyboxd: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("/root/.gnupg/.gitignore"), original
: "S.*", actual: "**/S.*", is_whitelist: false, is_only_dir: false })))
[DEBUG] (27) ignore::walk: ignoring /root/.python_history: Ignore(IgnoreMatch(Override(Glob(Matched(Glob { from: None, original: "!**/.*_histor
y", actual: "**/.*_history", is_whitelist: true, is_only_dir: false })))))
[DEBUG] (27) ignore::walk: ignoring /root/.ssh/id_rsa.pfx: Ignore(IgnoreMatch(Override(Glob(Matched(Glob { from: None, original: "!*.pfx", actu
al: "**/*.pfx", is_whitelist: true, is_only_dir: false })))))
[DEBUG] (27) ignore::walk: ignoring /root/.ssh/known_hosts.old: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("/root/.ssh/.gitignore"), origin
al: "*.old", actual: "**/*.old", is_whitelist: false, is_only_dir: false })))

check file being backed up

netbird-200:~/.ssh# rustic backup                                                                                             12:44:38 [5/7356]
using config /root/.config/rustic/rustic.toml
[INFO] repository rest:http://192.168.11.251:9999/: password is correct.
[INFO] using cache at /root/.cache/rustic/b042fb4f25867ac104f50eca8261ce6d96c585cf5663ccf6afd72547e2d20767
[00:00:00] reading index...               ████████████████████████████████████████          9/9
[INFO] using all backup sources from config file.
[INFO] merging source="/opt","/root","/usr/local/bin","/usr/local/etc" section from config file
[00:00:00] getting latest snapshot...     ████████████████████████████████████████        270/270
[INFO] using no parent
[INFO] starting to backup "/opt","/root","/usr/local/bin","/usr/local/etc"...
[00:00:08] backing up...                  ████████████████████████████████████████ 251.22 MiB/251.22 MiB 29.07 MiB/s  (ETA 0s)
Files:       785 new, 0 changed, 0 unchanged
Dirs:        24 new, 0 changed, 0 unchanged
Added to the repo: 12.9 kiB (raw: 44.4 kiB)
processed 785 files, 251.2 MiB
snapshot e2ed7de3 successfully saved.
[INFO] backup of "/opt","/root","/usr/local/bin","/usr/local/etc" done.
netbird-200:~/.ssh# rustic ls e2ed7de3:/root/.ssh
using config /root/.config/rustic/rustic.toml
[INFO] repository rest:http://192.168.11.251:9999/: password is correct.
[INFO] using cache at /root/.cache/rustic/b042fb4f25867ac104f50eca8261ce6d96c585cf5663ccf6afd72547e2d20767
[00:00:00] reading index...               ████████████████████████████████████████         10/10
[00:00:00] getting snapshot...            ████████████████████████████████████████          0/0
[INFO] getting snapshot...
".gitignore"
"authorized_keys"
"config"
"id_rsa"
"id_rsa.crt"
aawsome commented 10 months ago

Thank @kuyagic for opening the issue and sorry for the late reply! I think we must overwork the including excluding as there are more topics.

When doing the rework, we'll take into account how the let users define priorities between different include/exclude options.