GitHub - not-first/restic-glance-extension: A glance dashboard widget to show information about the latest snapshot of a restic repo. (original) (raw)

An extension widget API for the Glance dashboard.

Widget screenshot

A simple widget that shows information about the latest snapshot in a restic repo. Displays the short ID of the latest snapshot, and the time it was created in a human readable form. Also includes general information about the repo. Optionally, if autorestic is being used to back up it can show a small icon to indicate whether the backup was automatic or manual.

Setup

Docker Compose

Add the following to your existing glance docker compose

services: glance: image: glanceapp/glance # ...

restic-glance-extension: image: ghcr.io/not-first/restic-glance-extension ports: - '8675:8675' volumes: - /my/backup/location/repo1:/app/repos/repo1 - /my/backup/location/repo2-different-name:/app/repos/repo1 restart: unless-stopped env_file: .env

Environment Variables

This widget must be set up be providing environment variables, which can be added to your existing glance .env file. A full environment file might look like this:

RESTIC_REPOS=repo1,repo2 RESTIC_STATS_MODE=repository-size

REPO1_RESTIC_PASSWORD=mypassword1

REPO2_RESTIC_ENV__GOOGLE_APPLICATION_CREDENTIALS=app/config/credentials.json REPO2_RESTIC_URL=gs:be18b21d-4de1-4a41-a6dc-20a51251b058-repo2:repo2 REPO2_RESTIC_PASSWORD=mypassword2 REPO2_RESTIC_STATS_MODE=latest-snapshot

RESTIC_CACHE_INTERVAL=3600

The REPOS variable must contain comma seperated list of repo aliases, which are simple names you assign to allow the program to differentiate between repos. Additional configuration for the alias can be supplied with an environment variable starting with {PREFIX}_RESTIC_, where {PREFIX} is the capitalised alias of the repo.

Local repos must have a corresponding volume mount to the folder /app/repos/{alias}. See the provided .env.example and docker-compose.yml file above for a simple example. Note that this alias does not have to correspond to the name of the repo folder on your machine. Just where it is mounted to.

REPOS_BASE_PATH can be set to change the base directory from /app/repos, so the local repo urls will be computed as {REPOS_BASE_PATH}/{alias}.

RESTIC_CACHE_INTERVAL can be set to a time in seconds, where the cache will be updated with the repo info every interval. If not supplied it defaults to 3600 (1 hour).

RESTIC_STATS_MODE determines what statistics are displayed for your repositories. Valid values are:

You can override this setting per-repository using {PREFIX}_RESTIC_STATS_MODE. For example, you might want most repos to show disk usage but one specific repo to show latest snapshot size.

Glance Config

Next, add the extension widget into your glance page by adding this to your glance.yml.

The endpoint for your restic repo is accessible on the path /{repo-alias}, where {repo-alias} is the alias set for the repo in your .env file. In the example .env above, /repo1 or /repo2 would be used.

Parameters (all optional)

parameters: autorestic-icon: true hide-file-count: true limit: 1

autorestic-icon: An icon can be shown to indicate the method of backup (manual or cron). Give a value of 'true' to render it. This is detected using the tags that autorestic applies to snapshots, therefore using autorestic to manage the repo is required.

hide-file-count: Set to 'true' to hide the file count from the widget, showing only the number of snapshots and total size.

limit: The number of snapshots to render. Snapshots before the most recent one will render in a compressed list. See example below with limit set to 3

Example of widget with limit parameter set to 3