List exclusions

Is there a quick way to only list all files which would be excluded (if I use a filter expression)?

1 Like

Not directly. One way you can achieve this is by using the -vv argument when doing a backup.
I also recommend adding --dry-run to not create a snapshot but just show what it would exclude.

This would look like this. Note that I didn’t add any exclude arguments for this example.

❯ restic backup --compression=max --no-cache ~/Pictures -r repo --dry-run -vv
open repository
repository f83a2150 opened (version 2, compression level max)
lock repository
no parent snapshot found, will read all files
load index files
[0:00]          0 index files loaded
start scan on [/home/moritz/Pictures]
start backup on [/home/moritz/Pictures]
scan finished in 0.001s: 3 files, 1.211 MiB
new       /home/moritz/Pictures/FHY-RFiXsAwSS9F.jpeg, saved in 0.072s (445.418 KiB added)
new       /home/moritz/Pictures/FHY-RE9XMAQJplO.jpeg, saved in 0.075s (347.052 KiB added)
new       /home/moritz/Pictures/FHY-RFiXwBQH1f6.jpeg, saved in 0.084s (447.355 KiB added)
new       /home/moritz/Pictures/, saved in 0.088s (0 B added, 0 B stored, 492 B metadata)
new       /home/moritz/, saved in 0.089s (0 B added, 0 B stored, 297 B metadata)
new       /home/, saved in 0.091s (0 B added, 0 B stored, 291 B metadata)

Files:           3 new,     0 changed,     0 unmodified
Dirs:            3 new,     0 changed,     0 unmodified
Data Blobs:      3 new
Tree Blobs:      4 new
Would add to the repository: 1.213 MiB (1.212 MiB stored)

processed 3 files, 1.211 MiB in 0:00

alternatively you can use the JSON output in combination with jq to filter for this output in case the list is rather long.

This would look like this:

❯ restic backup --compression=max --no-cache -r repo --json -vv --dry-run ~/Pictures
{"message_type":"verbose_status","action":"scan_finished","item":"","duration":0.00090565,"data_size":1269581,"data_size_in_repo":0,"metadata_size":0,"metadata_size_in_repo":0,"total_files":3}
{"message_type":"status","percent_done":1,"total_files":3,"total_bytes":1269581,"bytes_done":1269581}
{"message_type":"status","percent_done":1,"total_files":3,"total_bytes":1269581,"bytes_done":1269581}
{"message_type":"status","percent_done":1,"total_files":3,"total_bytes":1269581,"bytes_done":1269581}
{"message_type":"status","percent_done":1,"total_files":3,"total_bytes":1269581,"bytes_done":1269581}
{"message_type":"verbose_status","action":"new","item":"/home/moritz/Pictures/FHY-RFiXsAwSS9F.jpeg","duration":0.072784999,"data_size":456108,"data_size_in_repo":456202,"metadata_size":0,"metadata_size_in_repo":0,"total_files":0}
{"message_type":"verbose_status","action":"new","item":"/home/moritz/Pictures/FHY-RFiXwBQH1f6.jpeg","duration":0.074468729,"data_size":458092,"data_size_in_repo":458186,"metadata_size":0,"metadata_size_in_repo":0,"total_files":0}
{"message_type":"verbose_status","action":"new","item":"/home/moritz/Pictures/FHY-RE9XMAQJplO.jpeg","duration":0.076414687,"data_size":355381,"data_size_in_repo":355472,"metadata_size":0,"metadata_size_in_repo":0,"total_files":0}
{"message_type":"verbose_status","action":"new","item":"/home/moritz/Pictures/","duration":0.07874387,"data_size":0,"data_size_in_repo":0,"metadata_size":1143,"metadata_size_in_repo":492,"total_files":0}
{"message_type":"verbose_status","action":"new","item":"/home/moritz/","duration":0.080021855,"data_size":0,"data_size_in_repo":0,"metadata_size":375,"metadata_size_in_repo":297,"total_files":0}
{"message_type":"verbose_status","action":"new","item":"/home/","duration":0.081416642,"data_size":0,"data_size_in_repo":0,"metadata_size":373,"metadata_size_in_repo":291,"total_files":0}
{"message_type":"status","percent_done":1,"total_files":3,"files_done":3,"total_bytes":1269581,"bytes_done":1269581}
{"message_type":"summary","files_new":3,"files_changed":0,"files_unmodified":0,"dirs_new":3,"dirs_changed":0,"dirs_unmodified":0,"data_blobs":3,"tree_blobs":4,"data_added":1271833,"total_files_processed":3,"total_bytes_processed":1269581,"total_duration":0.09216504,"snapshot_id":"ceed791ef3bcfebc56ae401a50348dda6fa94cc592354032616601fc40a459ce","dry_run":true}

This way you can compare the list of all files which actually exist (use any other tool to generate the list of all files) and the list created by restic.

I can’t think of another example but surely the rest of the community will jump in :slight_smile:

Thanks. That’s what was my solution. Just thought that there might be an easier way.

…and there might be :point_up: but I couldn’t think of another as you