-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (39 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# The [email protected] allows to backup arbitrary locations on the
# host file system.
#
# The unit is templated, which allows is it to be used with separate named
# configs. After installing the unit the following files need to be created
# in the `${CONFIG_DIR}/<instance-name>`
# directory.
#
# - `config.env`: containing any environment variables required to configure restic.
# This file must include the environment variables to configure the restic
# repository location and the password for it.
# See: https://restic.readthedocs.io/en/stable/040_backup.html#environment-variables
#
# - `files`: containing a list of patterns matching files and directories
# to back up. The file is passed to restic's --files-from option.
# See: https://restic.readthedocs.io/en/stable/040_backup.html#including-files
[Unit]
Description=Backup the file system using the configuration in ${CONFIG_DIR}/%I
ConditionFileNotEmpty=${CONFIG_DIR}/%I/config.env
ConditionFileNotEmpty=${CONFIG_DIR}/%I/files
ConditionFileIsExecutable=${REPO_DIR}/bash/check-snapshots
OnFailure=restic-backup-failed@%n
[Service]
Type=oneshot
KillMode=mixed
User=${RESTIC_USER}
Group=${RESTIC_GROUP}
EnvironmentFile=${CONFIG_DIR}/%I/config.env
AmbientCapabilities=CAP_DAC_READ_SEARCH
# Use the home directory of the restic user configured above.
WorkingDirectory=~
ExecCondition=${REPO_DIR}/bash/check-snapshots
ExecStart=/usr/bin/env restic backup \
--verbose \
--exclude-caches \
--tag %I \
--files-from ${CONFIG_DIR}/%I/files
[Install]
WantedBy=multi-user.target