I am running a nightly restic backup of my appdata directory. The snapshots
appear to be working. I can diff the snapshots and it only shows the changed
files. However, every snapshot says that it cannot find the parent snapshot.
When I run with -vv it finds files and marks them as “new” but it says “0 B
added, 0 B metadata”. Does anyone know why it wouldn’t find the parent
snapshot? I have pasted what I can tell is relevant below.
But when I do a backup it says it can’t find the parent and it shows those
files as new but unchanged.
# restic backup --iexclude-file=/var/lib/restic/excludes.txt /var/lib/appdata -vv
open repository
repository b09e5828 opened successfully, password is correct
lock repository
load index files
no parent snapshot found, will read all files
start scan on [/var/lib/appdata]
start backup on [/var/lib/appdata]
new /var/lib/appdata/edifier/.edifier/tmp/, saved in 0.002s (0 B added, 0 B metadata)
new /var/lib/appdata/edifier/.java/.userPrefs/.user.lock.root, saved in 0.002s (0 B added)
new /var/lib/appdata/edifier/.java/.userPrefs/.userRootModFile.root, saved in 0.001s (0 B added)
...
restic supports backing up multiple hosts to one repository. If you backup the same path of different hosts, it is useful to use the last snapshot with that path and the same host as parent - instead of the last snapshot with only a matching path (this might be the last backup of a different host)
But you are right, in the case that no parent is found, a parent with same path but different hostname might be still a good guess - feel free to open a github issue to request this as a future feature!
In the end this is not a big problem - the difference between finding a parent snapshot and not finding one is that in the latter case restic will have to rescan the files you back up to see if anything changed, whereas in the former case restic can instead just look at the metadata for the files to determine if they changed (assuming a trustworthy filesystem).
So, in the cases where this extra scanning is a problem because of a large dataset or similar, one can deal with it in other ways. The default is good as it is.
The help text for --parent in restic help backup mentions the default, yes. But it might be a good idea to explain the “parent” thing more explicitly in the documentation.
Thank you both for the explanation. I didn’t notice much of a performance issue, however there are thousands of files so I wasn’t sure what the impact would be later on. I set the hostname in docker and the problem went away.
I have a repo I’ve been running restic backup against nightly for three years by the way. It has saved me a number of times. Restic is one of my favorite pieces of software. Keep up the awesome work.
I also found this useful when trying to move a whole folder in my directory tree, without re-backing up everything.
For example, if you do this:
cd ~/path1/mydata
restic -r /srv/restic-repo backup .
mv ~/path1/mydata ~/path2/mydata
cd ~/path2/mydata
restic -r /srv/restic-repo backup .
…then in the second backup command, restic considers all the moved files as being new.
But if you do the same, except that you supply the snapshot ID from the first backup as the parent for the second backup, then moved (but unchanged) files aren’t re-backed up, so you save on time / bandwidth / space.
I think this relies on the fact that in both backups here, the files have the same path relative to the working directory that the command is executed from.