Continue if a file is not found

Below is the minimum reproducible command that leads to an error:

> restic backup "$env:APPDATA\Mozilla\Firefox\Profiles\34b32ksm.drum\user-overrides.js O:\artwork" --repo D:\restic --use-fs-snapshot
enter password for repository:
repository 16cdacef opened (version 2, compression level auto)
no parent snapshot found, will read all files
[0:00] 100.00%  5 / 5 index files loaded
VSS error: The caller does not have sufficient backup privileges or is not an administrator: E_ACCESSDENIED (0x80070005)

I do not have $env:APPDATA\Mozilla\Firefox\Profiles\34b32ksm.drum\user-overrides.js on this system. However, I would prefer not to adjust the command for every system continuously to match what paths are present, and what aren’t, which would be laborious and error-prone. Instead, I want restic to skip the files with a warning or an error message and continue backing up the remaining paths.

kopia behaves like that, as an example of what I mean.

  • Can you reproduce the same error with only any other non-existing backup path, e.g. C:\foo\bar (assuming that doesn’t exist)?
  • You have two paths in there, but talk only about the $env:APPDATA\Mozilla\Firefox\Profiles\34b32ksm.drum\user-overrides.js one. Can you verify that the same error happens when you have only that path as the backup set (and not the O:\artwork one at the same time)?

Restic happily skips files that don’t exist for me with a warning:

[11:25:40] root :: micro  ➜  ~ » restic -v backup /home/tim/THIS-TEST-DOES-NOT-EXIST /etc/passwd
/home/tim/THIS-TEST-DOES-NOT-EXIST does not exist, skipping
open repository
repository 275592a4 opened (version 2, compression level max)
lock repository
no parent snapshot found, will read all files
load index files
[0:01] 100.00%  16 / 16 index files loaded
start scan on [/etc/passwd]
start backup on [/etc/passwd]
scan finished in 2.373s: 1 files, 2.649 KiB

Files:           1 new,     0 changed,     0 unmodified
Dirs:            1 new,     0 changed,     0 unmodified
Data Blobs:      0 new
Tree Blobs:      2 new
Added to the repository: 738 B (596 B stored)

I think the error you’re getting there is something different to do with the --use-fs-snapshot command as it’s a VSS error, not a “file does not exist error” like in my output above.

1 Like

I tried the cases you described and a few more just to rule things out.

Snapshotting C:\foo\bar only, which doesn’t exist:

> restic backup "C:\foo\bar" --repo D:\restic --use-fs-snapshot                                   C:\foo\bar does not exist, skipping
Fatal: all target directories/files do not exist

Snapshotting overrides.js only, which doesn’t exist:

> restic backup "$env:APPDATA\Mozilla\Firefox\Profiles\34b32ksm.drum\user-overrides.js" --repo D:\restic --use-fs-snapshot
C:\Users\al\AppData\Roaming\Mozilla\Firefox\Profiles\34b32ksm.drum\user-overrides.js does not exist, skipping
Fatal: all target directories/files do not exist

Note: Neither of the above commands even asked for a password.

Snapshotting C:\foo\bar and overrides.js, neither of which exist:

> restic backup "$env:APPDATA\Mozilla\Firefox\Profiles\34b32ksm.drum\user-overrides.js C:\foo\bar" --repo D:\restic --use-fs-snapshot
enter password for repository:
repository 16cdacef opened (version 2, compression level auto)
no parent snapshot found, will read all files
[0:00] 100.00%  5 / 5 index files loaded
VSS error: The caller does not have sufficient backup privileges or is not an administrator: E_ACCESSDENIED (0x80070005)

This time I was asked for a password and got the original error.

Snapshotting O:\artwork and O:\interior, both of which exist:

> restic backup "O:\artwork O:\interior" --repo D:\restic --use-fs-snapshot                       enter password for repository:
repository 16cdacef opened (version 2, compression level auto)
no parent snapshot found, will read all files
[0:00] 100.00%  5 / 5 index files loaded
VSS error: The caller does not have sufficient backup privileges or is not an administrator: E_ACCESSDENIED (0x80070005)

Snapshotting just O:\interior:

> restic backup "O:\interior" --repo D:\restic --use-fs-snapshot
enter password for repository:
repository 16cdacef opened (version 2, compression level auto)
no parent snapshot found, will read all files
[0:00] 100.00%  5 / 5 index files loaded
VSS error: The caller does not have sufficient backup privileges or is not an administrator: E_ACCESSDENIED (0x80070005)

So I got the same error regardless of whether none of the files exist, both of the files exist, or it’s a mix of both, except for when snapshotting a single directory which doesn’t exist.

Oh I’m sorry!

The paths need to be fed as "dir 1" "dir 2" - which makes sense since the point of quotes is to account for whitespace, and whitespace is also the separator. This way it runs without issues and skips over errors. Thanks for the pointers.

Edit: Follow-up question: Is there a way to use the --use-fs-snapshot flag without running the elevated terminal? I thought placing the exe into System32 was supposed to achieve that.