Read only mount for latest snapshot with systemd

Hello all,
i use restic for all my backup needs and wanted to provide a readable snapshot of the latest backups over the web. I use this for media file which don’t change often.

The result looks like this:


root@xxx:/# tree -L 1 /mnt/cache/*/snapshots/latest/mnt/*/

/mnt/cache/assets/snapshots/latest/mnt/assets/
├── README.md
└── sw-software

/mnt/cache/audio/snapshots/latest/mnt/audio/
├── 01_klassik
└── ..

This is implemented with a systemd unit for each mount along the following lines :

[Unit]
Description=Mount the latest snapshot of the restic repository "{{ item.repo }}"" under "/mnt/cache/{{ item.repo }}/snapshot/latest"

StartLimitIntervalSec=500
StartLimitBurst=20

[Service]
User=root
Group=root
Type=simple
ExecStart=sh -c 'export RESTIC_PASSWORD="{{ item.passwd }}" ;/usr/local/bin/restic  mount --repo sftp:resticserver:{{ item.repo }} --no-lock   --allow-other       /mnt/cache/{{ item.repo }}'
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

This is in fact an ansible template but I think it is understandable.

This is a followup to an older question of mine

HTH

Norbert