aboutsummarylogtreecommitdiffstats
path: root/README.md
blob: 05851a3a1ca43197948f506fb5ced997407f0520 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# resticctl

The little helper of `restic`.

## Installation

Simply copy the `resticctl` bash script to `/usr/bin` or install it vía
[Arch Linux package][alp].

[alp]: https://aur.archlinux.org/packages/resticctl

## Configuration

The script reads the configuration in this preference order.

- `RESTICCTL_CONFIGURATION` variable
- `${XDG_CONFIG_HOME:-~/.config}/resticctl/resticctl.conf` user file
- `/etc/resticctl/resticctl.conf` global system file

The configuration is the definition of the environment variables that we
want to be present when `restic` is executed and some variables of the
script itself, which are the following.

- `BACKUP_LOCATIONS`, an array with the paths to include in the backup.
- `FORGET_FLAGS` (optional), an array with the modifiers that we want to
   pass to `restic forget` in case we want it to be executed before the
   `backup` command.

To find out which environment variables `restic` accepts you can consult its
documentation [here][env].

In addition, if in the location of `resticctl.conf` there is a file
`excludes.lst` then this file is used as a list of backup exclusion
patterns.

[env]: https://restic.readthedocs.io/en/stable/040_backup.html#environment-variables

## Run

The script has help, launch `resticctl` to see the subcommands.

At run time you can declare an environment variable `RESTIC_TAG` to set
a tag for the backup, if none is set, `manual` is used. If you need to
declare multiple tags simply separate them by commas, e.g. `export
RESTIC_TAG=manual,important,system`.

## Using it with systemd

If you want to run `resticctl` with `systemd` you can use the following
examples.

`/etc/systemd/system/resticctl-backup.service`
```systemd
[Unit]
Description=restic backup with resticctl
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
Nice=19
Environment="RESTIC_TAG=scheduled"
SuccessExitStatus=3
ExecStart=/usr/bin/resticctl backup
```

And to schedule it every four hours.

`/etc/systemd/system/resticctl-backup.timer`
```systemd
[Unit]
Description=restic backup with resticctl

[Timer]
OnCalendar=0/4:0
RandomizedDelaySec=30m
Persistent=true

[Install]
WantedBy=timers.target
```