3 A script for cloning systems using rsync.
4 Copyright (c)2008-2015 Alexander Barton <alex@barton.de>
11 Backup all or individual systems.
13 Usage: `backup-script [<options>] [<system> [<system> [...]]]`
17 - `-p`, `--progress`: Show progress, see rsync(1).
18 - `-n`, `--dry-run`: Test run only, don't copy any data.
20 When no *system* is given, all defined systems are backed up.
22 ### backup-script-wrapper
24 Backup all systems and mail the report to "root".
26 Usage: `backup-script-wrapper`
30 Show information about backups.
32 Usage: `backup-status [-q] [<system> [<system> [...]]]`
36 - `-q`: *quick mode*, don't calculate backup sizes.
41 All default configuration variables are read from the first file found of this
42 list: `/usr/local/etc/backup-scrupt.conf`, `/etc/backup-script.conf` or
43 from `/etc/backup-script.d/backup-script.conf` (deprecated).
45 All systems which should be backed-up are configured using individual files
46 in the configuration directory, which is `/usr/local/etc/backup-script.d/` or
47 `/etc/backup-script.d/` by default (whichever is found first), and can be
48 specified using the `conf_d` variable in the main configuration file.
50 The must be one file for each system to backup (files ending in `*.sh` are
51 skipped, as well as files named `backup-script.conf`). Please avoid spaces and
52 other "special" characters! The filename is used as hostname for the system by
53 default, but this can be overwritten using the `system` configuration variable.
55 Variables in `backup-script.conf` must be prefixed with `default_` to define
56 default values for all systems.
58 All defaults can be overwritten in the individual system configuration files.
62 - `/etc/backups-script.conf`: defaults for all hosts
63 - `/etc/backups-script.d/host01.example.net`: configuration for host 1
64 - `/etc/backups-script.d/clientXY.example.com`: configuration for host 2
67 ## Configuration Variables
71 System host name. Default: file name.
73 *Note:* There is no `default_system` variable!
75 ### [default_]backup_type
77 Backup type to use. Default: `rsync`.
79 - `rsync`: system backup using rsync(1).
80 Use `source_root` to specify the root directory to save.
82 - `scp`: file backup using scp(1).
83 Use `files` to specify the files to copy.
85 Please note that neither `ssh_args_add`, `rsync_args_add`, `compress`, nor any
86 "exclude" parameters are supported when using the "scp" backup type! And There
87 "scp" backup type never _deletes_ files from the backup store; so if you reduce
88 the list of files to backup, old files will still be kept, because they were
89 already saved in an older generation (but no longer updated).
93 Remote user. Default: `root`.
95 ### [default_]source_root
97 Remote *root* directory, must end with a slash ("/") character! Default: "/".
99 When saving the whole (remote) system ("/"), default excludes are set up
100 automatically, which exclude standard system directories like /sys and /proc.
104 Space separated list of files to copy when using the "scp" `backup_type`.
105 Default: "running-config".
109 Local backup directory. The backup of each system is stored in a folder named
110 like the system (see `system` variable) inside of this target directory.
112 *Note:* There is *no* default, you have to specify this variable, for example as
113 `default_target` in the `backups-script.conf` file!
115 ### [default_]ssh_args_add
117 Additional parameters for `ssh`. Default: none.
119 ### [default_]rsync_args_add
121 Additional parameters for `rsync`. Default: none.
123 ### [default_]exclude_args_add
125 Additional (exclude) parameters for `rsync`. Default: none.
127 *Deprecated! Use "exclude_dirs_add" instead!*
129 ### [default_]exclude_dirs_add
131 Additional directory path names to exclude from the backup. Use full path names
132 separated by spaces. Default: none.
134 ### [default_]compress
136 Enable (1) or disable (0) rsync transfer compression. Default: 1 (on).
140 Enable (1) or disable (0) ping'ing the target system to make sure that it is
141 reachable before calling `rsync`. Default: 1 (on).
145 Enable (1) or disable (0) *local mode*: when local mode is in effect, `rsync` is
146 called without using `ssh`, which is a good idea when saving the local system.
147 Default: 0 (off; use ssh).
149 ### [default_]generations
151 Number of generations to keep. Default: 0 (none).
153 On a suitable target file systems (see `target` variable), this script can
154 generate generations using snapshots: the script creates a new snapshot
155 named with the time stamp for each generation inside of the system directory
156 inside of the target directory.
158 Supported file systems are:
161 All generations are btrfs subvolumes and named after the date and time.
163 All generations are ZFS file systems. Latest generation is named `current`,
164 elders are links to the ZFS snapshot directories.
166 The latest snapshot is always reachable using a symlink named `latest`
167 inside the system directory.
169 ### [default_]job_pre_exec
171 Optional script to execute before `rsync` starts. Default: none.
173 When the `job_pre_exec` script returns an error (exit code is not 0), the backup
176 ### [default_]job_post_exec
178 Optional script to execute after `rsync` exited. Default: none.
180 ### Compatibility Variables
182 The following configurations variables used by the backup-pull(1) script in job
183 definition files are automatically mapped to the new backup-script variables:
186 * source -> source_root
187 * pre_exec -> job_pre_exec
188 * post_exec -> job_post_exec
193 - 1: Unspecific Error!
194 - 2: Usage information has been shown.
195 - 3: Can't read system definition
196 - 4: PID-file exists!
197 - 5: Pre-exec command failed!
198 - 6: There have been systems with errors!
199 - 7: Not all jobs were run!
200 - 9: Aborted (CTRL-C)!