NAME
rdiff-backup - local/remote mirror and incremental backupSYNOPSIS
rdiff-backup [options...] action [sub-options...] [locations...]DESCRIPTION
rdiff-backup is a script, written in python(1) that backs up one directory to another. The target directory ends up a copy (mirror) of the source directory, but extra reverse diffs are stored in a special sub-directory of that target directory, so you can still recover files lost some time ago. The idea is to combine the best features of a mirror and an incremental backup. rdiff-backup also preserves symlinks, special files, hardlinks, permissions, uid/gid ownership, and modification times. 1.generic options valid for all
actions,
2.one action out of backup,
calculate, complete, compare, info, list,
regress, remove, restore, server, test,
verify,
3.sub-options applicable to each action
specifically, even though some are common to multiple actions,
4.zero, one, two or more location paths,
either local or remote.
Options
-h, --helpPrints brief usage information and exits. Add
--new to be sure to get this CLI description, and not the old one.
Placed after the action, outputs the action’s specific help
message.
Prints the current version number and
exits.
Sets the API version to the given integer
between minimum and maximum versions as given by the info action. It is
the responsibility of the user to make sure that this version is also
supported by any server started by this client.
If the filesystem to which we are backing up
is not case-sensitive, automatic "quoting" of characters occurs. For
example, a file 'Developer.doc' will be converted into ';068eveloper.doc'. To
quote other characters or force quoting, e.g. in case rdiff-backup
doesn’t recognize a case-insensitive file system, you need to specify
this option. chars is a string of characters fit to be used in regexp
square brackets (e.g. 'A-Z' as in '[A-Z]').
Caution
do NOT change the chars to quote within the same repository!
Actually, you only need to set this parameter when creating a new backup
repository. Do also NOT quote any character used by rdiff-backup in
rdiff-backup-data (any of 'a-z0-9._-')!
This option is useful mainly for testing. If
set, rdiff-backup will use it for the current time instead of consulting the
clock. The argument is the number of seconds since the epoch.
Authorize a more drastic modification of a
directory than usual (for instance, when overwriting of a destination path, or
when removing multiple sessions with remove). rdiff-backup will
generally tell you if it needs this.
Caution
You can cause data loss if you mis-use this option.
Furthermore, do NOT use this option when doing a restore, as it will DELETE
files, unless you absolutely know what you are doing.
This will enable/disable issuing fsync from
rdiff-backup altogether. This option is designed to optimize performance on
busy backup systems.
Caution
This may render your backup unusable in case of filesystem failure.
Default is hence for fsync to be enabled.
enforce (or not) the usage of the new
parameters. The default currently is to show the old usage, but this will
change in the near future.
Use nulls (\0) instead of newlines (\n) as
line separators, which may help when dealing with filenames containing
newlines. This affects the expected format of the files specified by the
--{include|exclude}-filelist[-stdin] switches as well as the format of
the files statistics.
If set, rdiff-backup’s output will be
tailored for easy parsing by computers, instead of convenience for humans.
Currently this only applies when listing increments using the list
increments action, where the time will be given in seconds since the
epoch.
Specify an alternate method of connecting to a
remote computer. This is necessary to get rdiff-backup not to use ssh for
remote backups, or if, for instance, rdiff-backup is not in the PATH on the
remote side. See the REMOTE OPERATION section for details.
use path as temporary directory on the remote
side of the connection. If set explicitly, remember that "no space
left" error messages might apply to this directory.
use SSH with or without compression with
default remote-schema. This option is ignored when using
--remote-schema. Compression is on by default.
Sets the directory that rdiff-backup uses for
temporary files to the given path. The environment variables TMPDIR, TEMP, and
TMP can also be used to set the temporary files directory. See the
documentation of the Python tempfile module for more information. If set
explicitly, remember that "no space left" error messages
might apply to this directory.
select which verbosity to use for messages on
the terminal, the default is given by --verbosity.
Create timestamps in which the
hour/minute/second separator is a - (hyphen) instead of a : (colon). It is
safe to use this option on one backup, and then not use it on another;
rdiff-backup supports the intermingling of different timestamp formats. This
option is enabled by default on platforms which require that the colon be
escaped.
Specify verbosity level (0 is totally silent,
3 is the default, and 9 is noisiest). This determines how much is written to
the log file, and without using --terminal-verbosity to the
terminal..
Actions
backup [CREATION OPTIONS] [COMPRESSION OPTIONS] [SELECTION OPTIONS] [FILESYSTEM OPTIONS] [USER GROUP OPTIONS] [STATISTICS OPTIONS] sourcedir targetdirback-up a source directory to a target backup
repository.
calculate average across multiple statistics
files
--method average
there is currently only one method and it is
the default, but it might change in the future.
outputs a list of fitting options given
already entered parameters. This option is of no relevance to backup tasks, it
is only to be used to support programmatic completion like in bash. See the
documentation for more details if you plan to write your own completion code,
e.g. for an alternative shell.
--cword index
--unique,--no-unique
index where the cursor currently is within the
list of words.
should parameters already entered by the user
be offered again, or not?
Compare a directory with the backup set at the
given time. This can be useful to see how archived data differs from current
data, or to check that a backup is current.
--method method
--at time
method used to compare can be either
meta, full or hash, where the default is meta,
which is also how rdiff-backup decides which file needs to be backed-up. Note
that with full, the repository data will be copied in its entirety to
the source side and compared byte by byte. This is the slowest but most
complete compare method. With hash only the SHA1 checksum of regular
files will be compared. With meta only the metadata of files will be
compared (name, size, date, type, etc).
at which time of the back-up directory
should the comparaison take place. The default is now, meaning the
latest version. See TIME FORMATS for details.
outputs information about the current system
in YAML format, so that it can be used in a bug report, and exits.
list modified or existing files in a given
back-up repository.
--changed-since time
--at time
List the files that have changed in the
destination directory since the given time. See TIME FORMATS for the format of
time. If a directory in the archive is specified, list only the files under
that directory. This option does not read the source directory; it is used to
compare the contents of two different rdiff-backup sessions. See TIME FORMATS
for details.
List the files in the archive that were
present at the given time. If a directory in the archive is specified, list
only the files under that directory. See TIME FORMATS for details.
list increments with date in a given back-up
repository.
--no-size,--size
Show or not the size of each increment in the
repository. The default is to not show sizes. When showing sizes, it
becomes allowable to specify a directory within a repository, then only the
cumulated sizes of that directory will be shown.
If an rdiff-backup session fails, this action
will undo the failed directory. This happens automatically if you attempt to
back-up to a directory and the last backup failed. You can use the
--force option to undo the last backup even if it wasn’t
failed.
Remove the incremental backup information in
the destination directory that has been around longer than the given time, or
the oldest one if no time is provided.
By default, rdiff-backup will only delete information from one session at a
time. To remove two or more sessions at the same time, supply the
--force option (rdiff-backup will tell you if it is required).
Note that snapshots of deleted files are covered by this operation. Thus if you
deleted a file two weeks ago, backed up immediately afterwards, and then ran
rdiff-backup with 'remove increments --older-than 10D' today, no trace of that
file would remain.
--older-than time
--size
all the increments older than the given time
will be deleted. See TIME FORMATS for details.
Show the size of each increment being removed.
The default is to not show sizes.
restore a source backup repository at a
specific time or a specific source increment to a target directory. See
RESTORING for details.
--at time
--increment
the source parameter is interpreted as
a back-up directory, and the content is restored from the given time. See TIME
FORMATS for details.
the source parameter is expected to be
an increment within a back-up repository, to be restored into the given target
directory.
Enter server mode (not to be invoked directly,
but instead used by another rdiff-backup process on a remote computer).
--debug
Start the server in debug mode so that it
stops on an early breakpoint and can be remotely debugged using rpdb
<https://github.com/tamentis/rpdb>. See the developer’s
documentation
<https://github.com/rdiff-backup/rdiff-backup/blob/master/docs/DEVELOP.adoc#debug-client-server-mode>
for details.
Test for the presence of a compatible
rdiff-backup server as specified in the remote location argument(s) (of which
the filename section will be checked for existence). See the REMOTE OPERATION
section for details.
Check all the data in the repository at the
given time by computing the SHA1 hash of all the regular files and comparing
them with the hashes stored in the metadata file.
--at time
the time of the data which needs to be
verified. See TIME FORMATS for details.
COMPRESSION OPTIONS
--compression, --no-compressionEnable or disable the default gzip compression
of most of the .snapshot and .diff increment files stored in the
rdiff-backup-data directory. A backup volume can contain compressed and
uncompressed increments, so using this option inconsistently is fine. Default
is to compress all files, except those excluded as noted below.
Do not compress increments based on files
whose filenames match regexp. The default includes many common audiovisual and
archive files, and may be found from the help.
CREATION OPTIONS
--create-full-pathNormally only the final directory of the
destination path will be created if it does not exist. With this option, all
missing directories on the destination path will be created. Use this option
with care: if there is a typo in the remote path, the remote filesystem could
fill up very quickly (by creating a duplicate backup tree). For this reason
this option is primarily aimed at scripts which automate backups.
FILESYSTEM OPTIONS
--acls, --no-aclsenable/disable back-up of Access Control
Lists.
enable/disable back-up of carbon files (MacOS
X).
enable/disable back-up of Extended
Attributes.
enable/disable back-up of resource forks
(MacOS X).
do (or not) keep hard-link relationships
between files. Disabling hard-links generally increases the disk space usage
but decreases memory usage. Hard-links are disabled by default if the backup
source or restore destination is running on native Windows.
This option prevents rdiff-backup from
flagging a hardlinked file as changed when its device number and/or inode
changes. This option is useful in situations where the source filesystem lacks
persistent device and/or inode numbering. For example, network filesystems may
have mount-to-mount differences in their device number (but possibly stable
inode numbers); USB/1394 devices may come up at different device numbers each
remount (but would generally have same inode number); and there are
filesystems which don’t even have the same inode numbers from use to
use. Without the option rdiff-backup may generate unnecessary numbers of tiny
diff files.
Exit with error instead of dropping ACLs or
ACL entries. Normally this may happen (with a warning) because the destination
does not support them or because the relevant user/group names do not exist on
the destination side.
RESTRICT OPTIONS
--restrict-path dirpathRequire that all file access be inside the
given path. This switch, and --restrict-mode, are intended to be used
with the server action to provide a bit more protection when doing
automated remote backups.
Caution
Those options are not intended as your only line of defense so please
don’t do something silly like allow public access to an rdiff-backup
server run with --restrict-mode read-only.
restriction mode for the directory given by
--restrict-path, either full access (aka read-write), read-only, or
only to update incrementally an already existing back-up (default is
read-write).
SELECTION OPTIONS
This section only quickly lists the existing options, the section FILE SELECTION explains those more in details.Globs, Regex, File lists selection
--include,--exclude globInclude/exclude the file or files matched by
glob (also known as shell pattern). If a directory is excluded, then
files under that directory will also be excluded.
Include/exclude according to the listed globs,
similar to --include or --exclude.
Like the previous option but the list of globs
is coming from standard input.
Include/exclude files matching the given
regexp (according to Python rules).
Include/exclude the files listed in
filelist. This is a best fit for an automatically generated list of
files, else use globbing.
Like the previous but the filelist is coming
from standard input.
Special files selection
Include/exclude all device files. This can be
useful for security/permissions reasons or if rdiff-backup is not handling
device files correctly.
Include/exclude all fifo files.
Include/exclude all socket files.
Include/exclude all symbolic links. Contrary
to the general rule, symlinks are excluded by default under Windows so that
NTFS reparse points aren’t backed-up.
Include/exclude all the special files listed
above.
Other selections
--include-other-filesystems,--exclude-other-filesystemsInclude/exclude files on file systems
(identified by device number) other than the file system the root of the
source directory is on. The default is to include other filesystems.
Include/exclude directories if they contain
the given filename. Files directly in an included directory are also
considered included. This doesn’t apply recursively though so that the
filename must be present in all directories of a hierarchy for
it to be fully included.
Exclude files that are larger than the given
size in bytes.
Exclude files that are smaller than the given
size in bytes.
STATISTICS OPTIONS
--file-statistics, --no-file-statisticsEnable/disable writing to the
'file_statistics' file in the rdiff-backup-data directory. rdiff-backup
will run slightly quicker and take up a bit less space. Default is to write
the statistics file(s).
See the FILES section for more information about statistics files.
Summary statistics will be printed (or not)
after a successful backup. Even if disabled (the default), this information
will still be available from the session statistics file.
TIMESTAMP OPTIONS
--allow-duplicate-timestampsThis option is only to be used if you
encounter the issue of metadata mirrors with the same timestamp. In such
cases, you may use this flag to first recover from the failed backup with
something like
after which you will need to remove those old duplicate entries using the
remove increments action.
rdiff-backup --allow-duplicate-timestamps \ --check-destination-dir {targetdir}
USER GROUP OPTIONS
See the USERS AND GROUPS section for more information.Map group names and IDs according to the group
mapping file mapfile.
Map user names and IDs according to the user
mapping file mapfile.
If set, rdiff-backup will preserve uids/gids
instead of trying to preserve unames and gnames.
RESTORING
There are two ways to tell rdiff-backup to restore a file or directory: 1.you can run rdiff-backup restore on
a mirror file and define a time from which to restore (by default the latest
one).
2.you can run the restore action on an
increment file with the sub-option --increment.
rdiff-backup backup /usr /usr.backup
rdiff-backup restore --at 3D /usr.backup/local /usr/local.old
rdiff-backup restore --increment \ /backup/rdiff-backup-data/increments/usr/local.{time}.dir \ /usr/local.old
TIME FORMATS
rdiff-backup uses time strings in two places. 1.the string 'now' (refers to the current
time)
2.a sequences of digits, like '123456890'
(indicating the time in seconds after the epoch)
3.A string like '2002-01-25T07:00:00+02:00'
in datetime format
4.An interval, which is a number followed by
one of the characters s, m, h, D, W, M, or Y (indicating seconds, minutes,
hours, days, weeks, months, or years respectively), or a series of such pairs.
In this case the string refers to the time that preceded the current time by
the length of the interval. For instance, '1h78m"' indicates the time
that was one hour and 78 minutes ago. The calendar here is unsophisticated: a
month is always 30 days, a year is always 365 days, and a day is always 86400
seconds.
5.A date format of the form
"YYYY/MM/DD", "YYYY-MM-DD", "MM/DD/YYYY", or
"MM-DD-YYYY", which indicates midnight on the day in question,
relative to the current timezone settings. For instance, '2002/3/5',
'03-05-2002', and '2002-3-05' all mean March 5th, 2002 (needless to say that
starting with the year is less confusing for non-Americans).
6.A backup session specification which is a
non-negative integer followed by 'B'. For instance, '0B' specifies the time of
the current mirror, and '3B' specifies the time of the 3rd newest
increment.
REMOTE OPERATION
In order to access remote files, rdiff-backup opens up a pipe to a copy of rdiff-backup running on the remote machine. Thus rdiff-backup must be installed on both ends. To open this pipe, rdiff-backup first splits the location into 'host_info::pathname'. It then substitutes 'host_info' into the remote schema, and runs the resulting command, reading its input and output.•either '[user@]hostname'
•or a URI of the form
'ssh://[user@]hostname[:port]'.
rdiff-backup backup --remote-schema 'cd /usr; {h}' \ foo 'rdiff-backup server'::bar
rdiff-backup backup foo /usr/bar
ssh -C {h} /usr/local/lib/rdiff-backup-{Vx}.{Vy} --server
FILE SELECTION
rdiff-backup has a number of file selection options. When rdiff-backup is run, it searches through the given source directory and backs up all the files matching the specified options. This selection system may appear complicated, but it is supposed to be flexible and easy-to-use. If you just want to learn the basics, first look at the selection examples in the examples file included in the package, or on the web at <https://rdiff-backup.net/docs/examples.html>. 1.pattern matching is stupid about paths, it
just does pattern matching and can’t interpret patterns like path,
especially it can’t resolve absolute into relative paths and vice-versa
(compare with the '-path' option of find).
2.pattern matching is done on the complete
path of each found file (no partial matching and no file name matching).
Beware that complete path does not mean full path, it can be a complete
relative path.
rdiff-backup backup --include /usr \ --exclude /usr /usr /backup
rdiff-backup backup /usr /backup
rdiff-backup backup --include /usr/local/bin \ --exclude /usr/local /usr /backup
1.pattern can be expanded into the
file’s filename, or
2.the file is inside a directory matched by
the option.
1.pattern can be expanded into the
file’s filename,
2.the file is inside a directory matched by
the option, or
3.the file is a directory which contains a
file matched by the option.
--exclude /usr/local
--exclude /usr/local --exclude '/usr/local/**'
--include /usr/local
--include ignorecase:'/usr/[a-z0-9]foo/*/**.py'
1.Globbing patterns like '*', '**', '?', and
'[...]' are not expanded.
2.Include patterns do not match files in a
directory that is included. So '/usr/local' in an include file will not match
'/usr/local/doc'.
3.Lines starting with '+ [...]' (plus
followed by a space) are interpreted as include directives, even if found in a
filelist referenced by --exclude-filelist. Similarly, lines starting
with '- [...]' (minus followed by a space) exclude files even if they are
found within an include filelist.
/usr/local - /usr/local/doc /usr/local/bin + /var - /var
dir/foo
--include dir/foo --include dir/bar --exclude **
--include '[0-9]{7}(?!foo)'
USERS AND GROUPS
There can be complications preserving ownership across systems. For instance the username that owns a file on the source system may not exist on the destination. Here is how rdiff-backup maps ownership on the source to the destination (or vice-versa, in the case of restoring): 1.If the --preserve-numerical-ids
option is given, the remote files will always have the same uid and gid, both
for ownership and ACL entries. This may cause unames and gnames to
change.
2.Otherwise, attempt to preserve the user and
group names for ownership and in ACLs. This may result in files having
different uids and gids across systems.
3.If a name cannot be preserved (e.g. because
the username does not exist), preserve the original id, but only in cases of
user and group ownership. For ACLs, omit any entry that has a bad user or
group name.
4.The --user-mapping-file and
--group-mapping-file options override this behavior. If either of these
options is given, the policy described in 2 and 3 above will be followed, but
with the mapped user and group instead of the original. If you specify both
--preserve-numerical-ids and one of the mapping options, the behavior
is undefined.
old_name_or_id1:new_name_or_id1 old_name_or_id2:new_name_or_id2 [...etc...]
FILES
any-config-fileyou can create a file with one
option/action/sub-option per line and use it on the command line with an at
sign prefix like @any-config-file and its content will be interpreted
as if given on the command line.
For example, creating a file 'mybackup' with following content:
and calling 'rdiff-backup @mybackup' will be the same as calling 'rdiff-backup
--verbosity 5 backup source_dir target_dir'.
--verbosity 5 backup source_dir target_dir
Every session rdiff-backup saves various
statistics into two files, the session statistics file at
'rdiff-backup-data/session_statistics.{datetime}.data' and the files
statistics at 'rdiff-backup-data/directory_statistics.{datetime}.data'. They
are both text files and contain similar information: how many files changed,
how many were deleted, the total size of increment files created, etc.
However, the session statistics file is intended to be very readable and only
describes the session as a whole. The files statistics file is more compact
(and slightly less readable) but describes every directory backed up. It also
may be compressed to save space.
See also STATISTICS OPTIONS and the --null-separator option.
rdiff-backup will save various messages to the
log file, which is 'rdiff-backup-data/backup.log' for backup sessions and
'rdiff-backup-data/restore.log' for restore sessions. Generally what is
written to this file will coincide with the messages displayed to stdout or
stderr, although this can be changed with the --terminal-verbosity
option.
Errors during backup are also written to a file
'rdiff-backup-data/error_log.{datetime}.data'.
The log files are not compressed and can become quite large if rdiff-backup is
run with high verbosity.
ENVIRONMENT
RDIFF_BACKUP_VERBOSITY= [0-9]the default verbosity for log file and
terminal, can be overwritten by the corresponding options
-v/--verbosity and --terminal-verbosity.
set a non-default listening address and/or
port (default is 127.0.0.1:4444) for rpdb. Valid values are address,
address:port or :port.
RETURN CODES
The following return codes have not been fully implemented so test before you rely on them. Also note that they can be combined, so that for example a return code 3 might be returned if a warning was found, then an error.the action was completely successful
something fatal happened, the whole action
failed
any kind of unexpected behavior without
complete failure
the action failed on a single file (or more),
but it wasn’t the reason for a complete failure
the action stumbled on a single file (or
more), or detected differences in a comparaison
BUGS
See GitHub issuesAUTHORS
•Ben Escoto
<[email protected]> (retired)
•Eric Lavarde
<[email protected]> (active)
SEE ALSO
python(1), rdiff(1), rsync(1), ssh(1).January 2023 | rdiff-backup |