Restic backup Summary and diff does not match

I am using restic 0.17.3 to run backups with --json flag. I am not sure if it’s a bug or a limitation, but the output at the end of the backup does not specify when a file/folder is removed. Here is a sample output of a restic backup command after removing a file:

{
     message_type: 'summary',
     files_new: 0,
     files_changed: 0,
     files_unmodified: 88,
     dirs_new: 0,
     dirs_changed: 4,
     dirs_unmodified: 1,
     data_blobs: 0,
     tree_blobs: 4,
     data_added: 3526,
     data_added_packed: 2016,
     total_files_processed: 88,
     total_bytes_processed: 176650704,
     total_duration: 0.022724,
     snapshot_id: '8316562f69be88fa743b0751c9eb08ca5baff5a4a0eb826c2a59ea5dd70f9a51'
}

But after the backup, when I run the restic diff command to compare the latest snapshot with the previous one, I get the correct stats:

{
    "message_type": "statistics",
    "source_snapshot": "f05fdae4",
    "target_snapshot": "8316562f",
    "changed_files": 0,
    "added": {
        "files": 0,
        "dirs": 0,
        "others": 0,
        "data_blobs": 0,
        "tree_blobs": 5,
        "bytes": 9323
    },
    "removed": {
        "files": 1,
        "dirs": 0,
        "others": 0,
        "data_blobs": 0,
        "tree_blobs": 5,
        "bytes": 10175
    }
}

I am guessing restic actually prints out the move/copy stats at the end of the backup, but not the actual change counts like the diff command does. Is it possible to incorporate the removed count in the summary of the backup summary output (files_removed, dirs_removed)?

Best Regards

The way restic works, the backup command makes sure all files it has to backup are in the repository. So it creates references if the files are already in the backup and it adds data if something has changed or new files were created in the source. That’s what’s reported in your first JSON output. The backup command does not care if there have been more files in the past – if a file is not present in the source it does not need a reference. Only forget and prune will actually remove things.

Removing files or directories is just something the backup command does not take notice of. It could of course run a diff internally but so can the user if he is interested.

1 Like