Restic restore: incorrect/different files count

The following commands init a new repository and performs a backup of a single file.
restic backup correctly counts files (1) and dirs (4).
restic restore counts 5 files.


mkdir {repo,restore}
mkdir -p data/foo/bar/baz
echo foo>data/foo/bar/baz/test

restic init

restic backup data
# Files:           1 new,     0 changed,     0 unmodified
# Dirs:            4 new,     0 changed,     0 unmodified
# Added to the repository: 2.379 KiB (1.931 KiB stored)
# processed 1 files, 4 B in 0:00

restic restore -t restore latest 
# Summary: Restored 5 Files (4 B) in 0:00

restic restore -t restore latest --json
# {"message_type":"summary","total_files":5,"files_restored":5,"total_bytes":4,"bytes_restored":4}

This is probably because restic treats directories like files, but it’s mildly confusing nevertheless.
Is this a bug or the desired behaviour introduced by #4315 which adjusted the way restic counts to match restic stats (which only shows total file count)?

Hmm, that’s rather a case of suboptimal naming: restored 5 items (objects?) would be more precise. The output is currently consistent with that of the stats command, that would also report that your test snapshot contains Total File Count: 5.

I see, would you accept a PR which changes the naming?

We can change the text output, the JSON field names should remain unchanged. The main question is what the proper replacement for “files” should be.

“objects” would seem to be a fitting replacement?

Coming from Linux where “everything is a file”, “files” sounds good for me. With “objects”, I rather think of internal blob files (like git objects)… so I’d personall still prefer “files”.

What about something like Summary: Restored 5 files/directories (4 B) in 0:00?

1 Like

It’s slightly verbose but definitely better than the current state. Could you open a PR for that?

Sure :slight_smile: Gave it a try in Tweak restore summary by lbausch · Pull Request #4487 · restic/restic · GitHub