If a file is unchanged, does a restore overwrite or skip it?

When we do a restore, does restic overwrite destination files that have the same content and metadata as the snapshot version?

Thats the current behavior. Note there is

which would change this.

Thanks very much. I’m very surprised to see this isn’t the default behaviour. I hope that PR gets merged soon!

I also found these relevant issues:

In lieu of a feature like this, I used restic mount (described here) and rclone sync (described here) and it seems to work quite well - only downloading files that are different, and removing ones that don’t exist in the restic repo.

Note that for that solution, rclone needs to read local existing files as well as the data for those files saved in the repository (in order to do the comparison). This might be ok for local repositories but can be expensive or slow for remote repositories - especially if most local files are already in a correct state.

The PR I proposed instead only needs to read the local files, and hashes the chunks of the local files as defined by the repository metadata in order to know which actual data is really needed from the repository.

1 Like

It may not work for all situations but you could do a “restic backup --dry-run” now. The --dry-run will tell you which files are different based on meta data. You would likely need to manipulate the output to put it into a format which could be used for a restore but running this would give you a relatively quick way to see the differences between source files and backup repository using existing commands.

Two ocomments about this:

  • first, if you want to get information about restoring a specific snapshot in this way, please don’t forget to use that snapshot as parent by specifying --parent. If you don’t, the newest snapshot will be taken as “comparison”.
  • second, yes, this compares the parent snapshot with the data on-disc. But it doesn’t use all metadata, but only file sizes, modification time and inode number. If you want to compare the file contents with the ones saved in the repo, the backup command is not useful: Either it uses a parent and then does not read the file if it matches. Or there is no parent (e.g. when running with --force) then backup will read, chunk and hash the file but only checks if that chunk is available in the repo and not if the file is identical to the corresponding file in the snapshot.

So for a dry-run check if local contents equal to snapshot contents, a combination of #3425 and this PR

would be the best way!