]> arthur.barton.de Git - backup-script.git/blob - README.md
Streamline and document exit codes
[backup-script.git] / README.md
1 # Backup Script
2
3 A script for cloning systems using rsync.  
4 Copyright (c)2008-2015 Alexander Barton <alex@barton.de>
5
6
7 ## Usage
8
9 ### backup-script
10
11 Backup all or individual systems.
12
13 Usage: `backup-script [<options>] [<system> [<system> [...]]]`
14
15 Options:
16
17 - `-p`, `--progress`: Show progress, see rsync(1).
18 - `-n`, `--dry-run`: Test run only, don't copy any data.
19
20 When no *system* is given, all defined systems are backed up.
21
22 ### backup-script-wrapper
23
24 Backup all systems and mail the report to "root".
25
26 Usage: `backup-script-wrapper`
27
28 ### backup-status
29
30 Show information about backups.
31
32 Usage: `backup-status [-q] [<system> [<system> [...]]]`
33
34 Options:
35
36 - `-q`: *quick mode*, don't calculate backup sizes.
37
38
39 ## Configuration
40
41 All default configuration variables are read from `/etc/backup-script.conf` or
42 from `/etc/backup-script.d/backup-script.conf` (deprecated). The individual
43 systems are configured using individual files in `/etc/backup-script.d/`, one
44 for each system to backup (files ending in `*.sh` are skipped, as well as
45 files named `backup-script.conf`). Please avoid spaces and other "special"
46 characters!
47
48 Variables in `backup-script.conf` must be prefixed with `default_` to define
49 default values for all systems.
50
51 All defaults can be overwritten in individual system configuration files.
52
53 For example:
54
55 - `/etc/backups-script.conf`: defaults for all hosts
56 - `/etc/backups-script.d/host01.example.net`: configuration for host 1
57 - `/etc/backups-script.d/clientXY.example.com`: configuration for host 2
58
59
60 ## Configuration Variables
61
62 ### system
63
64 System host name. Default: file name.
65
66 *Note:* There is no `default_system` variable!
67
68 ### [default_]user
69
70 Remote user. Default: `root`.
71
72 ### [default_]source_root
73
74 Remote *root* directory, must end with a slash ("/") character! Default: "/".
75
76 When saving the whole (remote) system ("/"), default excludes are set up
77 automatically, which exclude standard system directories like /sys and /proc.
78
79 ### [default_]target
80
81 Local backup directory. The backup of each system is stored in a folder named
82 like the system (see `system` variable) inside of this target directory.
83
84 *Note:* There is *no* default, you have to specify this variable, for example as
85 `default_target` in the `backups-script.conf` file!
86
87 ### [default_]ssh_args_add
88
89 Additional parameters for `ssh`. Default: none.
90
91 ### [default_]rsync_args_add
92
93 Additional parameters for `rsync`. Default: none.
94
95 ### [default_]exclude_args_add
96
97 Additional (exclude) parameters for `rsync`. Default: none.
98
99 ### [default_]compress
100
101 Enable (1) or disable (0) compression. Default: 1 (on).
102
103 ### [default_]ping
104
105 Enable (1) or disable (0) ping'ing the target system to make sure that it is
106 reachable before calling `rsync`. Default: 1 (on).
107
108 ### [default_]local
109
110 Enable (1) or disable (0) *local mode*: when local mode is in effect, `rsync` is
111 called without using `ssh`, which is a good idea when saving the local system.
112 Default: 0 (off; use ssh).
113
114 ### [default_]generations
115
116 Number of generations to keep. Default: 0 (none).
117
118 On a suitable target file systems (see `target` variable), this script can
119 generate generations using snapshots: the script creates a new snapshot
120 named with the time stamp for each generation inside of the system directory
121 inside of the target directory.
122
123 Supported file systems are:
124
125  * *btrfs*:
126    All generations are btrfs subvolumes and named after the date and time.
127  * *ZFS*:
128    All generations are ZFS file systems. Latest generation is named `current`,
129    elders are links to the ZFS snapshot directories.
130
131 The latest snapshot is always reachable using a symlink named `latest`
132 inside the system directory.
133
134 ### [default_]job_pre_exec
135
136 Optional script to execute before `rsync` starts. Default: none.
137
138 When the `job_pre_exec` script returns an error (exit code is not 0), the backup
139 run is skipped!
140
141 ### [default_]job_post_exec
142
143 Optional script to execute after `rsync` exited. Default: none.
144
145 ### Compatibility Variables
146
147 The following configurations variables used by the backup-pull(1) script in job
148 definition files are automatically mapped to the new backup-script variables:
149
150 * host -> system
151 * source -> source_root
152 * pre_exec -> job_pre_exec
153 * post_exec -> job_post_exec
154
155
156 ## Exit codes
157
158 - 1: Unspecific Error!
159 - 2: Usage information has been shown.
160 - 3: Can't read system definition
161 - 4: PID-file exists!
162 - 5: Pre-exec command failed!
163 - 6: There have been systems with errors!
164 - 9: Aborted (CTRL-C)!