summaryrefslogtreecommitdiff
path: root/doc/rsbackup.1
blob: 13e0d3ab405013fe24d016b9613f0b1eb5243f32 (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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
.TH rsbackup 1
.\" Copyright (c) 2011, 2012, 2014-15, 2017-18 Richard Kettlewell
.\"
.\" This program is free software: you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation, either version 3 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program.  If not, see <http://www.gnu.org/licenses/>.
.SH NAME
rsbackup \- rsync-based backup utility
.SH SYNOPSIS
\fBrsbackup\fR [\fIOPTIONS\fR] [\fB\-\-\fR] [\fISELECTOR\fR...]
.br
\fBrsbackup \-\-retire [\fIOPTIONS\fR] [\fB\-\-\fR] [\fISELECTOR\fR...]
.br
\fBrsbackup \-\-retire\-device [\fIOPTIONS\fR] [\fB\-\-\fR] \fIDEVICE\fR...
.SH DESCRIPTION
\fBrsbackup\fR backs up files from one or more (remote) destinations to a single
backup storage directory, preserving their contents, layout,
ownership, permissions, timestamps and hardlink structure.
.PP
Incremental backups are achieved by hard-linking identical files
within successive backups of the same files.
.PP
See \fBrsbackup\fR(5) for details of the configuration file.
.SH OPTIONS
.SS "Action Options"
At least one of these options must be specified.
When multiple actions are specified, they are executed in the order
shown below.
.TP
.B \-\-backup\fR, \fB\-b
Make a backup of the selected volumes.
At most one backup of a given volume will be made per day.
.TP
.B \-\-retire\-device
Retire the named devices.
Retiring a device only means deleting the records of it.
Files on the device itself are not touched.
.IP
If the device is still listed in the configuration file then you will
be asked whether you really want to retire it; you can suppress this
check with the \fB\-\-force\fR option.
.TP
.B \-\-retire
Retire the named hosts and volumes.
Retiring a volume means deleting any available backups for the volume
and the records of them.
Records corresponding to backups on unavailable devices are not removed.
.IP
If you just want to remove backup records for retired volumes but want
to keep the backups, you should either manually remove the records
(see \fBSCHEMA\fR below),
or
rename it within the volume.
.IP
Since this command deletes backups, you will be prompted to confirm it.
You can suppress this
check with the \fB\-\-force\fR option.
.TP
.B \-\-forget\-only
With \fB\-\-retire\fR, suppresses deletion of backups, and instead
just drops database records for the hosts and volumes affected.
.TP
.B \-\-prune\fR, \fB\-p
Prune old backups of selected volumes.
See \fBrsbackup\fR(5) for details how how pruning is controlled.
.TP
.BR \-\-prune\-incomplete, \fB\-P
Prune incomplete backups of selected volumes.
Any backups that failed before completion will be removed.
.TP
.B \-\-html \fIPATH\fR, \fB\-H \fIPATH
Write an HTML report to \fIPATH\fR.
The report covers all volumes, not just selected ones.
\fIPATH\fR can be \fB\-\fR to write to standard output.
.TP
.B \-\-text \fIPATH\fR, \fB\-T \fIPATH
Write a plain text report to \fIPATH\fR.
The report covers all volumes, not just selected ones.
\fIPATH\fR can be \fB\-\fR to write to standard output.
.TP
.B \-\-email \fIADDRESS\fR, \fB\-e \fIADDRESS
Email a report to \fIADDRESS\fR.
The contents is equivalent to the output of \fB\-\-text\fR and
\fB\-\-html\fR.
.TP
.B \-\-dump\-config
Writes the parsed configuration file to standard output.
Must not be combined with any other action option.
.IP
With \fB\-\-verbose\fR, the configuration file is annotated with
descriptive comments.
.SS "General Options"
.TP
.B \-\-config \fIPATH\fR, \fB\-c \fIPATH
The path to the configuration file.
The default is
.IR /etc/rsbackup/config .
.TP
.B \-\-store \fIPATH\fR, \fB\-s \fIPATH
Specify the destination directory to back up to.
Using this option (possibly more than once) is equivalent to removing
the \fBstore\fR directives from the configuration file and replacing
them with the paths give in \fB\-\-store\fR options.
.IP
This option implicitly enables the \fB\-\-warn\-store\fR option.
.TP
.B \-\-unmounted\-store \fIPATH\fR
Equivalent to \fB\-\-store\fR except that the store does not have to
be a mount point.
.TP
.B \-\-verbose\fR, \fB\-v
Enable verbose mode.
Various messages will be displayed to report progress and the rsync
\fB\-\-quiet\fR option is suppressed.
.TP
.B \-\-dry\-run\fR, \fB\-n
Enable dry-run mode.
Commands will be displayed but nothing will actually be done.
.TP
.B \-\-force\fR, \fB\-f
Suppress checks made when retiring devices and volumes.
.TP
.B \-\-wait\fR, \fB\-w
Waits rather than giving up if another copy of \fBrsbackup\fR is running.
.TP
.B \-\-database\fR, \fB\-D \fIPATH
Override the path to the backup database.
.TP
.B \-\-help\fR, \fB\-h
Display a usage message.
.TP
.B \-\-version\fR, \fB\-V
Display the version number.
.SS "Report Verbosity"
.TP
.B \-\-logs \fIVERBOSITY\fR
Controls which logfiles for a given volume/device pair to include in
the report.
The possible values of \fIVERBOSITY\fR are:
.RS
.TP
.B all
Includes all nonempty logfiles, even if the backup succeeded.
.TP
.B errors
Includes all error logfiles.
.TP
.B recent
Includes only the most recent error logfile.
.TP
.B latest
Includes only the latest logfile, even if the backup succeeded.
.TP
.B failed
Includes only the most recent logfile but only if that attempt failed.
This is the default.
.RE
.SS "Warning Options"
.TP
.B \-\-warn\-unknown
Display warnings for unknown devices, hosts and volumes.
(Warnings will always be included in the report, this refers to
runtime error output.)
.TP
.B \-\-warn\-store
Display warnings for unsuitable store directories and unavailable devices.
.TP
.B \-\-warn\-unreachable
Display warnings for unreachable hosts.
.TP
.B \-\-no\-warn\-partial
Suppress warnings for rsync "partial transfer" diagnostics
(which are on by default).
.TP
.B \-\-warn\-all\fR, \fB\-W
Enable all \fB\-\-warn\-\fR options.
.TP
.B \-\-no\-errors
Suppress display of errors from rsync.
.SS "Volume Selection"
The list of selectors on the command line determines what subset of
the known volumes are backed up, pruned or retired.
The following selectors are possible:
.TP 16
.I HOST
Select all volumes for the host.
.TP
.IR HOST : VOLUME
Select the volume.
.TP
.BI \- HOST
Deselect all volumes for the host.
.TP
.BI \- HOST : VOLUME
Deselect the volume.
.TP
.B *
Select all volumes.
.PP
If no hosts or volumes are specified on the command line then all volumes are
selected for backing up or pruning.
For retiring, you must explicitly select hosts or volumes to retire
and only positive selections are possible.
.SH "BACKUP LIFECYCLE"
.SS "Adding A New Host"
To add a new host create a \fBhost\fR entry for it in the configuration file.
.PP
To back up the local host, specify \fBhostname localhost\fR.
Otherwise you can usually omit \fBhostname\fR.
.PP
You may want to set host-wide values for \fBprune\-age\fR,
\fBmax\-age\fR and \fBmin\-backups\fR.
.PP
A host with no volumes has no effect.
.SS "Adding A New Volume"
To add a new volume create a \fBvolume\fR entry for it in the relevant
\fBhost\fR section of the configuration file.
.PP
Add \fBexclude\fR options to skip files you don't want to back up.
This might include temporary files and the contents of "trash"
directories.
.PP
If the volume contains mount points, and you want to back up the
contents of the subsiduary filesystems, then be sure to include the
\fBtraverse\fR option.
.PP
You may want to set per-volume values for \fBprune\-age\fR,
\fBmax\-age\fR and \fBmin\-backups\fR.
.SS "Adding A New Device"
To add a new device, format and mount it and create a
\fIdevice\-id\fR file in its top-level directory.
Add a \fBdevice\fR entry for it in the configuration file and a
\fBstore\fR entry mentioning its usual mount point.
.PP
Under normal circumstances you should make sure that the backup
filesystem is owned by root and mode 0700.
.SS "Making Backups"
To backup up all available volumes to all available devices:
.in +4n
.nf

rsbackup \-\-backup

.fi
.in
You will probably want to automate this.
To only back up a limited set of volumes specify selection arguments
on the command line.
.SS "Pruning Backups"
To prune old backups:
.in +4n
.nf

rsbackup \-\-prune \-\-prune\-incomplete

.fi
.in
You will probably want to automate this.
.PP
An "incomplete backup" occurs when a backup of a volume fails or is
interrupted before completion.
They are not immediately deleted because \fBrsync\fR may be able to
use the files already transferred to save effort on subsequent backups
on the same day, or (if there are no complete backups to use for this
purpose) later days.
.SS "Retiring A Host"
Retiring a host means removing all backups for it.
The suggested approach is to remove configuration for it and then use
\fBrsbackup \-\-retire \fIHOST\fR to remove its backups too.
You can do this the other way around but you will be prompted to check
you really meant to remove backups for a host still listed in the
configuration file.
.PP
If any of the backups for the host are on a retired device you should
retire that device first.
.SS "Retiring A Volume"
Retiring a volume means removing all backups for it.
It is almost the same as retiring a whole host but the command is
\fBrsbackup \-\-retire \fIHOST\fB:\fIVOLUME\fR.
.PP
You can retire multiple hosts and volumes in a single command.
.SS "Retiring A Device"
Retiring a device just means removing the records for it.
Use \fBrsbackup \-\-retire\-device \fIDEVICE\fR to do this.
The contents of the device are not modified; if you want that you must
do it manually.
.PP
You can retire multiple devices in a single command.
.SH RESTORING
Restore costs extra l-)
.SS "Manual Restore"
The backup has the same layout, permissions etc as the original
system, so it's perfectly possible to simply copy files from a backup
directory to their proper location.
.PP
Be careful to get file ownership right.
The backup is stored with the same numeric user and group ID as the
original system used.
.PP
Until a backup is completed, or while one is being pruned,
a corresponding \fB.incomplete\fR file
will exist.
Check for such a file before restoring any given backup.
.SS "Restoring With rsync"
Supposing that host \fBchymax\fR has a volume called \fBusers\fR in
which user home directories are backed up, and user \fBrjk\fR wants
their entire home directory to be restored, an example restore
command might be:
.in +4n
.nf

rsync \-aSHAXz \-\-numeric\-ids /store/chymax/users/2010-04-01/rjk/. chymax:~rjk/.

.fi
.in
.PP
You could add the \fB\-\-delete\fR option if you wanted to restore to
exactly the status quo ante, or at the opposite extreme
\fB\-\-existing\fR if you only wanted to restore files that had been
deleted.
.PP
You might prefer to rsync back into a staging area and then pick files
out manually.
.SS "Restoring with tar"
You could tar up a backup directory (or a subset of it) and then untar
it on the target.
Remember to use the \fB\-\-numeric\-owner\fR option to tar.
.SH "STORE VALIDITY"
A store may be in the following states:
.IP \fBavailable
The store can be used for a backup.
.IP \fBunavailable
The store cannot be used for a backup.
Normally this does not generate an error but \fB\-\-warn\-store\fR can
be used to report warnings for all unavailable stores, and if no store
is available then the problems with the unavailable stores are described.
.IP \fBbad
The store cannot be used for a backup.
This always generates an error message, but does not prevent backups
to other stores taking place.
.IP "\fBfatally broken"
The store cannot be used for a backup.
The program will be terminated.
.PP
The states are recognized using the following tests (in this order):
.IP \(bu
If the store path does not exist, the store is bad.
.IP \(bu
If the store does not have a \fBdevice\-id\fR file then it is
unavailable.
If it has one but reading it raises an error then it is bad.
.IP \(bu
If the store's \fBdevice\-id\fR file contains an unknown device name
then it is bad.
.IP \(bu
If the store's \fBdevice\-id\fR file names the same device as some
other store then it is fatally broken.
.IP \(bu
If the store is not owned by \fBroot\fR then it is bad.
This check can be overridden with the \fBpublic\fR directive.
.IP \(bu
If the store can be read or written by group or world then it is bad.
This check can be overridden with the \fBpublic\fR directive.
.SH FILES
.TP
.I /etc/rsbackup/config
Configuration file.
See \fBrsbackup\fR(5)
.TP
.I LOGS/backups.db
The backup records.
See \fBSCHEMA\fR below.
.TP
.I STORE/HOST/VOLUME/YYYY\-MM\-DD
One backup for a volume.
.TP
.I STORE/HOST/VOLUME/YYYY\-MM\-DD.incomplete
Flag file for an incomplete backup.
.SH SCHEMA
.I backups.db
is a SQLite database.
It contains a single table with the following definition:
.nf

CREATE TABLE backup (
  host TEXT,
  volume TEXT,
  device TEXT,
  id TEXT,
  time INTEGER,
  pruned INTEGER,
  rc INTEGER,
  status INTEGER,
  log BLOB,
  PRIMARY KEY (host,volume,device,id)
)

.fi
Each row represents a completed backup.
The meanings of the fields are as follows:
.TP 10
.B host
The name of the host the backup was taken from.
.TP
.B volume
The name of the volume the backup was taken from.
.TP
.B device
The name of the device the backup was written to.
.TP
.B id
The unique identifier for the backup.
Currently this is the date the backup was made, in the format YYYY-MM-DD
but this may be changed in the future.
.TP
.B time
The time that the backup was started, as a \fBtime_t\fR.
.TP
.B pruned
The time that backup pruning started (if it is underway) or finished
(if it is complete), as a \fBtime_t\fR.
.TP
.B rc
The exit status of the backup process.
0 means success.
.TP
.B status
Status of this backup.
See below.
.TP
.B log
The log output of \fBrsync\fR(1) and hooks.
If the backup status is pruning or pruned (see below) then this
contains the reason for the pruning.
.PP
Possible status values are:
.TP
.B 0
Unknown status.
Not normally seen.
.TP
.B 1
Internally this means the backup is underway.
If seen externally after \fBrsbackup\fR terminates it means the backup
is incomplete.
.TP
.B 2
Backup is complete.
.TP
.B 3
Backup has failed.
.TP
.B 4
Pruning has started.
.TP
.B 5
Pruning has completed.
.PP
\fBrsbackup\fR is not designed with concurrent access to this table in
mind.
Therefore it is recommended that you only modify its contents when the
program is not running.
.SH "HISTORICAL BEHAVIOR"
Older versions of \fBrsbackup\fR stored the logs for each backup in a
separate file.
If such files are encountered then \fBrsbackup\fR will automatically
populate \fIbackups.db\fR from them and then delete them.
.PP
Older versions of \fBrsbackup\fR logged pruning information to a
pruning logfile.
These files will be deleted at the same rate as records of pruned
backups in the database.
They are not included in the report.
.SH "SEE ALSO"
\fBrsbackup\-graph\fR(1),
\fBrsbackup.cron\fR(1),
\fBrsbackup\-mount\fR(1),
\fBrsbackup\-snapshot\-hook\fR(1),
\fBrsync\fR(1),
\fBrsbackup\fR(5)
.SH AUTHOR
Richard Kettlewell <rjk@greenend.org.uk>