Hi!
I use Restic for personal backups, so I like to always do a dry run with -vv
to see which files and folders would be added, deleted and/or modified. However, I noticed that Restic only shows new and modified files and folders, but not deleted ones. Is this expected?
Thanks!
I think that the “problem” is that conceptually restic does not delete anything hence there is nothing to report:). It adds files to a snapshot and tries to reuse any chunks already stored in repository (does not matter if from the last snapshot or some older ones).
Possibly logging “deletions” can be implemented - I am not an expert on restic internals. But I think there are many more urgent and important things in the pipeline…
You can always use restic diff
to find all changes between two snapshots.
1 Like
Yes, I know that. I meant more in the sense of seeing what was removed from that snapshot, because from the moment I delete the older snapshots, files that were deleted there will no longer be accessible.
It works, but would be better if there was a single command to compare the latest snapshot with the earlier one, without needing to list snapshots and copying-paste its IDs.
This is where the misunderstanding begins. Nothing is removed from that snapshot.
When doing a backup run, restic adds data to the repo and meta data to the new snapshot, in order for you to later be able to restore the files in that snapshot. When collecting this data and meta data, files which no longer exist in the source data have no relevance at all to the new snapshot.
In a backup run, you can ask restic to print what it’s doing. It does not mention what it is NOT doing.
If you want to know about the diff, use restic diff
.
2 Likes
If it is something you run very frequently then automate it yourself. Wrap restic diff
in some script extracting IDs of two latests snapshots. And share it on the forum for others.
2 Likes
@martinleben @kapitainsky Sure, I understand Restic don’t really delete files in new snapshots, I just thought I could list all differences before backup, using dry run.
I made a simple Python script that gets the two latest snapshots IDs and run the diff command automatically. Thanks for the help!
import subprocess
# Run the command that lists snapshots
listSnapshotsOutput = subprocess.run('restic -r example:backup snapshots', shell=True, text=True, capture_output=True).stdout
# Separate the output of the command in lines, reversed
dividedOutput = list(reversed(listSnapshotsOutput.splitlines()))
# Get the two IDs of the current and previous snapshots
latestSnapshotID, penultimateSnapshotID = dividedOutput[2][:8], dividedOutput[3][:8]
print(subprocess.run(f'restic -r example:backup diff {penultimateSnapshotID} {latestSnapshotID}', shell=True, text=True, capture_output=True).stdout)
2 Likes