aboutsummaryrefslogtreecommitdiffstats
path: root/lifeboat.1
blob: d821f1124f51eca0e368ec5c8221de8cb5a36ee0 (plain) (blame)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
.Dd October 11, 2024
.Dt LIFEBOAT 1
.Os
.Sh NAME
.Nm lifeboat
.Nd manage and automate local restic backups
.Sh SYNOPSIS
.Nm
.Ar name
.Ar command
.Sh DESCRIPTION
.Nm
is a program that manages a set of local
.Xr restic 1
repositories and provides a framework
for automating the creation and synchronization of backups.
.Pp
The name refers to any valid backup under
.Ev LIFEBOAT_ROOT .
.Pp
The command is any command recognized by
.Xr restic 1 ,
or as follows:
.Bl -tag -width Ds
.It Sy run
Create a snapshot for the specified repository.
.It Sy run-report
Like
.Sy run ,
but send any program output to the mail address specified in
.Pa config/recipient .
.El
.Sh DIRECTORY STRUCTURE
.Nm
keeps all its backups under one directory, specified by the
.Ev LIFEBOAT_ROOT
environment variable.
If unset,
.Nm
will fall back to
.Pa /srv/backup/lifeboat .
.Pp
Each backup managed by
.Nm
owns a directory under
.Ev LIFEBOAT_ROOT .
In that directory, the program expects the following:
.Bl -tag -width Ds
.It Sy repo/
A directory containing the actual
.Xr restic 1
repository.
.It Sy config/include
A file containing paths to include in the backup, one per line.
See the
.Em --files-from
option in
.Xr restic-backup 1 .
.It Sy config/exclude
A file containing paths that are excluded from the backup, one per line.
See the
.Em --exclude-file
option in
.Xr restic-backup 1 .
.It Sy config/sync
A file containing synchronization targets for
.Xr rclone 1 ,
one per line.
The format for a synchronization target is the base
.Xr rclone 1
destination, then optionally a tab character and a size limit in kibibytes.
.Pp
.Nm
will append the name of the backup
.Ev ( LIFEBOAT_REPO_NAME )
to the base destination.
.Pp
For example, the following configuration will synchronize a backup named
.Dq server
to
.Pa nas:backups/server
if the combined size of the repository is below 10G:
.Bd -literal -offset indent
nas:backups/	10485760
.Ed
.It Sy config/recipient
A file containing the mail address of the recipient for backup reports.
Only needed for the
.Sy run-report
command.
.It Sy credentials/restic
A file containing the password for the
.Xr restic 1
repository.
.It Sy run
A shell script containing backup jobs, optional
.It Sy retain
A shell script pruning old backups or enforcing retainment policies, optional.
.It Sy clean
A shell script containing cleanup jobs, optional.
.It Sy sync
A shell script containing synchronization jobs, optional.
.El
.Pp
If any of the optional scripts exist,
.Nm
will execute those instead of its inbuilt defaults.
.Pp
By default,
.Nm
will honor the given include and exclude directives, retain 7 daily,
5 weekly, 12 monthly, and 2 yearly backups,
verify and clean up the repository using
.Xr restic-check 1
and
.Xr restic-prune 1 ,
and sync the repo to the given synchronization targets.
.Pp
Note that by default,
.Nm
will look for a binary named
.Em restic-priv
with which to run the backup job itself.
As per upstream recommendation this is the restic binary with the
.Em cap_dac_read_search
capability set.
This allows restic to access any file on the system without
needing root permissions.
.Pp
We recommend running
.Nm lifeboat
under its own user account, with only that user account having access
to the
.Em restic-priv
binary.
To facilitate this,
.Nm lifeboat
extends
.Ev PATH
with the
.Pa bin/
directory under
.Ev HOME .
.
.Sh ENVIRONMENT
.Nm
will export the following environment variables for use in the
.Em run ,
.Em retain ,
.Em clean ,
and
.Em sync
scripts:
.Bl -tag -width Ds
.It Sy LIFEBOAT_REPO_NAME
The name of the backup as specified on the command line.
.It Sy RESTIC_REPOSITORY
The path to the
.Xr restic 1
repository.
.It Sy RESTIC_PASSWORD_FILE
The path to the
.Xr restic 1
password file.
.El
.Sh SEE ALSO
.Xr restic 1
.Sh AUTHORS
.An -nosplit
.Nm
was written by
.An Wolfgang Müller Aq Mt wolf@oriole.systems