Implement web server to view backups · Issue #60 · restic/restic

I would like to work on this issue. The ideas is to implement a vanilla Go http server with some basic html template. Our use case is to have some universal basic interface for Restic under Windows
Here is the scope of my task:

Problem
Restic does not provide a handy way to browse through the backups on Windows.

Task
Try to implement a basic proof of concept of a built-in web server, that allows browsing and restoring the backups using a browser.

Example
Executing the following commands will create two backups and you learn how to browse the backups via the command line.

openssl rand -hex 10 > ~/.restic-password
restic -p ~/.restic-password init --repo /tmp/backup

Make a backup

restic -p ~/.restic-password --repo /tmp/backup backup ~

Make some changes

date > ~/file-with-changes.txt

Make the next backup

restic -p ~/.restic-password --repo /tmp/backup backup ~

Look what backups you have

restic -p ~/.restic-password --repo /tmp/backup snapshots

repository 2ad83051 opened successfully, password is correct
ID Time Host Tags Paths

b8ee7b24 2020-09-11 17:20:17 thorsten-devvm-v3 /root
99388d0b 2020-09-11 17:21:23 thorsten-devvm-v3 /root

2 snapshots

Look what what's inside a backup

restic -p ~/.restic-password --repo /tmp/backup ls -l 99388d0b

Get a json formatted list of all files in the backup.

restic -p ~/.restic-password --repo /tmp/backup ls -l --json 99388d0b|jq

Check if a file is in the backup

restic -p ~/.restic-password --repo /tmp/backup find snmp.json

Restore a file

restic -p ~/.restic-password --repo /tmp/backup restore latest --target /tmp/restore --include "/root/snmp.json"
Specifications
By executing something like that, the webserver starts, and internally the backup is "open".
restic -p ~/.restic-password --repo /tmp/backup webserver 127.0.0.1:3344

Pointing my browser to HTTP://127.0.0.1:3344 I get the list of all snapshots in the repository. It's the same data, that restic -p ~/.restic-password --repo /tmp/backup snapshots shows.

I can click on the ID on the first column and I get a tree-view of all files in the snapshot. The same data as restic -p ~/.restic-password --repo /tmp/backup ls -l --json returns is displayed. The tree-view doesn't need folding and unfolding nor icons at the beginning.

Or I can click on a path of a snapshot (5th column) and I get a list of files in the backup belonging only to this path. It displays the same data as restic -p ~/.restic-password --repo /tmp/backup ls -l --path --json

I can click on a single file and download it through the browser.

Ideally, I can click on a file and I get a list of all different versions ordered by date of that file.
A snaphot always gives a virtual view of the entire file system. To identify the different versions of a file the following command would be used on the command line.
restic -p ~/.restic-password --repo /tmp/backup find /root/snmp.json --json|jq
All objects, where mtime is identical must be reduced to a single object because files haven't changed.