Features | Documentation | Installation | Config File Syntax | Usage | systemd
rsnapshot-ng comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions. See the GNU General Public Licence for details.
rsnapshot-ng is a fork of rsnapshot including some basic improvements and a modern build/test environment.
- rsnapshot is a filesystem snapshot utility based on rsync. rsnapshot makes it easy to make periodic snapshots of local machines, and remote machines over ssh/rsyncd.
- The code makes extensive use of hard links whenever possible, to greatly reduce the disk space required.
- It is written entirely in perl with no module dependencies, and has been tested with versions 5.14 through 5.24. It should work on any reasonably modern UNIX compatible OS.
- The HOWTO will give you a detailed walk-through on how to get rsnapshot up and running in explicit detail.
- Config files can contain spaces and tabs as delimiters
- Pure Perl script without build system - you can used it directly on any device (just modify the config)
rsync
output is shown on verbosity level >= 3- Advanced Javascript based testcases
Some recommended tutorials/usage guides
- rsnapshot HOWTO
- archlinux.de - Tutorial
- ubuntuusers.de - Tutorial
- thomas-krenn.com - Backup unter Linux mit rsnapshot
There are currently two different methods available to install rsnapshot-ng
Just download the latest release from GitHub and extract the files in a directory of your choice (/opt/rsnapshot-ng
for example).
Add Repository
Installation
apt-get update
apt-get install rsnapshot-ng
- The config file syntax has been changed
- The deprecated config directive
interval
has been removed (replaced byretain
)
- Linux based OS
- At a minimum:
perl
(>= 5.14 required),rsync
(>=3.1.1 recommended) - Optionally:
ssh
,logger
, GNUcp
, GNUdu
The config file syntax has changed compared to the classic rsnapshot files.
Now it's allowed to use any kind of whitespaces (spaces and tabs) as command/value delimiter. To identify the "new" version you have to set config_version 2.0
(compatibility)
Syntax: keyword value0
[value1
[ value2
]]
Paths with Whitespaces
To use whitespaces within paths, just wrap the argument into double-quotes
backup "/etc/my dir with whitespaces" etcbackup/ +rsync_short_args=-z
Once you have installed rsnapshot, you will need to configure it.
The default configuration file is /etc/rsnapshot.conf
, although the exact path may be different depending on how the program was installed.
If this file does not exist, copy rsnapshot.conf
over to /etc/rsnapshot.conf
and edit it to suit your tastes.
See the docs for the full list of configuration options.
When /etc/rsnapshot.conf
contains your chosen settings, do a quick sanity check to make sure everything is ready to go:
Testing your config
$ rsnapshot configtest
Dry-Run - show what will happen
If this works, you can see essentially what will happen when you run it for real by executing the following command (where interval is alpha
, beta
, etc
):
$ rsnapshot -t [interval]
Backups Stages
The number of snapshots that are saved depends on the retain settings in /etc/rsnapshot.conf
retain alpha 6
This means that every time rsnapshot alpha
is run, it will make a new snapshot, rotate the old ones, and retain the most recent six (alpha.0
- alpha.5
).
Note that the backups are done from the highest interval first (in this case delta
) and go down to the lowest interval.
If you are not having cron invoke the alpha
snapshot interval, then you must also ensure that alpha
is not listed as one of
your intervals in rsnapshot.conf (for example, comment out alpha, so that beta
becomes the lowest interval).
Remember that it is only the lowest interval which actually does the rsync to back up the relevant source directories, the higher
intervals just rotate snapshots around. Unless you have enabled sync_first
in your configuration-file, in which case only the sync
pseudo-interval does the actual rsync, and all real intervals just rotate snapshots.
Cronjob Example
Once you are happy with everything, the final step is to setup a cron job to automate your backups.
Here is a quick example which makes alpha
backups every four hours, beta
backups every day, gamma
backups every tuesday and delta
backups 1st of month
File: /etc/cron.d/rsnapshot
# cron-config - m h dom mon dow <user> <command>
# alpha backups, each 4hours
0 */4 * * * root /usr/bin/rsnapshot alpha
# beta backups, daily @3:00am
0 3 * * * root /usr/bin/rsnapshot beta
# gamma backups, weekly @tuesday 2:40am
40 2 * * 2 root /usr/bin/rsnapshot gamma
# delta backups, monthly 1st @2.20am
20 2 1 * * root /usr/bin/rsnapshot delta
rsnapshot-ng comes with systemd based invocation (service+timer) to easily handle backup tasks.
The rsnapshot program is triggerd via a linked systemd-instance service file - therefore you do not need additional service files.
Example: Run Tasks alpha+beta manually
systemctl start [email protected]
systemctl start [email protected]
Example: Run Task alpha automatically
For each triggerd interval you have to create a custom systemd-timer based on the example below.
File: /etc/systemd/system/rsnapshot-alpha.timer
[Unit]
Description=rsnapshot backup task alpha
[Timer]
# Run rsnapshot interval "alpha" at 04:30 am
OnCalendar=04:30
# do NOT start backup immediately if its missed (servers..)
Persistent=false
# linked unit
[email protected]
[Install]
WantedBy=timers.target
Enable Timer
systemctl daemon-reload
systemctl enable rsnapshot-alpha.timer
systemctl start rsnapshot-alpha.timer
View Active Timers
systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Fri 2017-11-10 04:30:00 UTC 17h left n/a n/a rsnapshot-daily.timer [email protected]
Tue 2017-11-14 04:00:00 UTC 4 days left n/a n/a rsnapshot-weekly.timer [email protected]
Fri 2017-12-01 03:50:00 UTC 3 weeks 0 days left n/a n/a rsnapshot-monthly.timer [email protected]
Example: daily/weekly/monthly schedules
A common used backup scheme/configuration is available within the systemd/ directory including pre-configured timers:
Please see the AUTHORS file for the complete list of contributors.
rsnapshot-ng is OpenSource and licensed under the Terms of GNU General Public Licence v2. You're welcome to contribute!
Many Thanks to the contributors of rsnapshot and Mike Rubel author of rsync_snapshots