Advertisement
Guest User

rdiff-backup

a guest
Jul 10th, 2023
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.67 KB | None | 0 0
  1. RDIFF-BACKUP(1) User Manuals RDIFF-BACKUP(1)
  2.  
  3. NAME
  4. rdiff-backup - local/remote mirror and incremental backup
  5.  
  6. SYNOPSIS
  7. rdiff-backup [options] [[[user@]host1.foo]::source_directory] [[[user@]host2.foo]::destination_directory]
  8.  
  9. rdiff-backup {{ -l | --list-increments } | --remove-older-than time_interval | --list-at-time time | --list-changed-since time | --list-increment-sizes | --verify | --verify-at-time
  10. time} [[[user@]host2.foo]::destination_directory]
  11.  
  12. rdiff-backup --calculate-average statfile1 statfile2 ...
  13.  
  14. rdiff-backup --test-server [user1]@host1.net1::path [[user2]@host2.net2::path] ...
  15.  
  16. DESCRIPTION
  17. 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
  18. are stored in a special subdirectory 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 incremen‐
  19. tal backup. rdiff-backup also preserves symlinks, special files, hardlinks, permissions, uid/gid ownership, and modification times.
  20.  
  21. rdiff-backup can also operate in a bandwidth efficient manner over a pipe, like rsync(1). Thus you can use ssh and rdiff-backup to securely back a hard drive up to a remote location,
  22. and only the differences will be transmitted. Using the default settings, rdiff-backup requires that the remote system accept ssh connections, and that rdiff-backup is installed in
  23. the user's PATH on the remote system. For information on other options, see the section on REMOTE OPERATION.
  24.  
  25. Note that you should not write to the mirror directory except with rdiff-backup. Many of the increments are stored as reverse diffs, so if you delete or modify a file, you may lose
  26. the ability to restore previous versions of that file.
  27.  
  28. Finally, this man page is intended more as a precise description of the behavior and syntax of rdiff-backup. New users may want to check out the examples.html file included in the
  29. rdiff-backup distribution.
  30.  
  31. OPTIONS
  32. --allow-duplicate-timestamps
  33. This 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
  34. backup with something like rdiff-backup --allow-duplicate-timestamps --check-destination-dir <targetdir> after which you will need to remove those old duplicate entries using
  35. the --remove-older-than parameter.
  36.  
  37. -b, --backup-mode
  38. Force backup mode even if first argument appears to be an increment or mirror file.
  39.  
  40. --calculate-average
  41. Enter calculate average mode. The arguments should be a number of statistics files. rdiff-backup will print the average of the listed statistics files and exit.
  42.  
  43. --carbonfile
  44. Enable backup of MacOS X carbonfile information.
  45.  
  46. --check-destination-dir
  47. If an rdiff-backup session fails, running rdiff-backup with this option on the destination dir will undo the failed directory. This happens automatically if you attempt to back
  48. up to a directory and the last backup failed.
  49.  
  50. --compare
  51. This is equivalent to '--compare-at-time now'
  52.  
  53. --compare-at-time time
  54. 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. This
  55. only compares metadata, in the same way rdiff-backup decides whether a file has changed.
  56.  
  57. --compare-full
  58. This is equivalent to '--compare-full-at-time now'
  59.  
  60. --compare-full-at-time time
  61. Compare a directory with the backup set at the given time. To compare regular files, the repository data will be copied in its entirety to the source side and compared byte by
  62. byte. This is the slowest but most complete compare option.
  63.  
  64. --compare-hash
  65. This is equivalent to '--compare-hash-at-time now'
  66.  
  67. --compare-hash-at-time time
  68. Compare a directory with the backup set at the given time. Regular files will be compared by computing their SHA1 digest on the source side and comparing it to the digest
  69. recorded in the metadata.
  70.  
  71. --create-full-path
  72. Normally 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 cre‐
  73. ated. 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
  74. this option is primarily aimed at scripts which automate backups.
  75.  
  76. --current-time seconds
  77. 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
  78. the epoch.
  79.  
  80. --exclude shell_pattern
  81. Exclude the file or files matched by shell_pattern. If a directory is matched, then files under that directory will also be matched. See the FILE SELECTION section for more
  82. information.
  83.  
  84. --exclude-device-files
  85. Exclude all device files. This can be useful for security/permissions reasons or if rdiff-backup is not handling device files correctly.
  86.  
  87. --exclude-fifos
  88. Exclude all fifo files.
  89.  
  90. --exclude-filelist filename
  91. Excludes the files listed in filename. If filename is handwritten you probably want --exclude-globbing-filelist instead. See the FILE SELECTION section for more information.
  92.  
  93. --exclude-filelist-stdin
  94. Like --exclude-filelist, but the list of files will be read from standard input. See the FILE SELECTION section for more information.
  95.  
  96. --exclude-globbing-filelist filename
  97. Like --exclude-filelist but each line of the filelist will be interpreted according to the same rules as --include and --exclude.
  98.  
  99. --exclude-globbing-filelist-stdin
  100. Like --exclude-globbing-filelist, but the list of files will be read from standard input.
  101.  
  102. --exclude-other-filesystems
  103. Exclude files on file systems (identified by device number) other than the file system the root of the source directory is on.
  104.  
  105. --exclude-regexp regexp
  106. Exclude files matching the given regexp. Unlike the --exclude option, this option does not match files in a directory it matches. See the FILE SELECTION section for more in‐
  107. formation.
  108.  
  109. --exclude-special-files
  110. Exclude all device files, fifo files, socket files, and symbolic links.
  111.  
  112. --exclude-sockets
  113. Exclude all socket files.
  114.  
  115. --exclude-symbolic-links
  116. Exclude all symbolic links. This option is automatically enabled if the backup source is running on native Windows to avoid backing-up NTFS reparse points.
  117.  
  118. --exclude-if-present filename
  119. Exclude directories if filename is present. This option needs to come before any other include or exclude options.
  120.  
  121. --force
  122. 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-older-
  123. than). rdiff-backup will generally tell you if it needs this. WARNING: You can cause data loss if you mis-use this option. Furthermore, do NOT use this option when doing a
  124. restore, as it will DELETE FILES, unless you absolutely know what you are doing.
  125.  
  126. --group-mapping-file filename
  127. Map group names and ids according the the group mapping file filename. See the USERS AND GROUPS section for more information.
  128.  
  129. --include shell_pattern
  130. Similar to --exclude but include matched files instead. Unlike --exclude, this option will also match parent directories of matched files (although not necessarily their con‐
  131. tents). See the FILE SELECTION section for more information.
  132.  
  133. --include-filelist filename
  134. Like --exclude-filelist, but include the listed files instead. If filename is handwritten you probably want --include-globbing-filelist instead. See the FILE SELECTION section
  135. for more information.
  136.  
  137. --include-filelist-stdin
  138. Like --include-filelist, but read the list of included files from standard input.
  139.  
  140. --include-globbing-filelist filename
  141. Like --include-filelist but each line of the filelist will be interpreted according to the same rules as --include and --exclude.
  142.  
  143. --include-globbing-filelist-stdin
  144. Like --include-globbing-filelist, but the list of files will be read from standard input.
  145.  
  146. --include-regexp regexp
  147. Include files matching the regular expression regexp. Only files explicitly matched by regexp will be included by this option. See the FILE SELECTION section for more informa‐
  148. tion.
  149.  
  150. --include-special-files
  151. Include all device files, fifo files, socket files, and symbolic links.
  152.  
  153. --include-symbolic-links
  154. Include all symbolic links.
  155.  
  156. --list-at-time time
  157. 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.
  158.  
  159. --list-changed-since time
  160. 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
  161. 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.
  162.  
  163. -l, --list-increments
  164. List the number and date of partial incremental backups contained in the specified destination directory. No backup or restore will take place if this option is given.
  165.  
  166. --list-increment-sizes
  167. List the total size of all the increment and mirror files by time. This may be helpful in deciding how many increments to keep, and when to --remove-older-than. Specifying a
  168. subdirectory is allowable; then only the sizes of the mirror and increments pertaining to that subdirectory will be listed.
  169.  
  170. --max-file-size size
  171. Exclude files that are larger than the given size in bytes
  172.  
  173. --min-file-size size
  174. Exclude files that are smaller than the given size in bytes
  175.  
  176. --never-drop-acls
  177. 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
  178. user/group names do not exist on the destination side.
  179.  
  180. --no-acls
  181. No Access Control Lists - disable backup of ACLs
  182.  
  183. --no-carbonfile
  184. Disable backup of MacOS X carbonfile information
  185.  
  186. --no-compare-inode
  187. 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
  188. 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 in‐
  189. ode 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
  190. the same inode numbers from use to use. Without the option rdiff-backup may generate unnecessary numbers of tiny diff files.
  191.  
  192. --no-compression
  193. 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
  194. uncompressed increments, so using this option inconsistently is fine.
  195.  
  196. --no-compression-regexp regexp
  197. Do not compress increments based on files whose filenames match regexp. The default includes many common audiovisual and archive files, and may be found in Globals.py.
  198.  
  199. --no-eas
  200. No Extended Attributes support - disable backup of EAs.
  201.  
  202. --no-file-statistics
  203. This will 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.
  204.  
  205. --no-fsync
  206. This will disable issuing fsync from rdiff-backup altogether. This option is designed to optimize performance on busy backup systems. Use with caution. This may render your
  207. backup unusable in case of filesystem failure.
  208.  
  209. --no-hard-links
  210. Don't replicate hard links on destination side. If many hard-linked files are present, this option can drastically decrease memory usage. This option is enabled by default if
  211. the backup source or restore destination is running on native Windows.
  212.  
  213. --null-separator
  214. 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 speci‐
  215. fied by the --{include|exclude}-filelist[-stdin] switches as well as the format of the directory statistics file.
  216.  
  217. --parsable-output
  218. 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
  219. -l or --list-increments switches, where the time will be given in seconds since the epoch.
  220.  
  221. --override-chars-to-quote
  222. 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
  223. ';068eveloper.doc'. To override this behavior, you need to specify this option.
  224.  
  225. --preserve-numerical-ids
  226. If set, rdiff-backup will preserve uids/gids instead of trying to preserve unames and gnames. See the USERS AND GROUPS section for more information.
  227.  
  228. --print-statistics
  229. If set, summary statistics will be printed after a successful backup. If not set, this information will still be available from the session statistics file. See the STATISTICS
  230. section for more information.
  231.  
  232. -r, --restore-as-of restore_time
  233. Restore the specified directory as it was as of restore_time. See the TIME FORMATS section for more information on the format of restore_time, and see the RESTORING section for
  234. more information on restoring.
  235.  
  236. --remote-cmd cmd
  237. Deprecated. Please use --remote-schema instead
  238.  
  239. --remote-schema schema
  240. 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
  241. not in the PATH on the remote side. See the REMOTE OPERATION section for more information.
  242.  
  243. --remote-tempdir path
  244. Adds the --tempdir option with argument path when invoking remote instances of rdiff-backup.
  245.  
  246. --remove-older-than time_spec
  247. Remove the incremental backup information in the destination directory that has been around longer than the given time. time_spec can be either an absolute time, like
  248. "2002-01-04", or a time interval. The time interval is an integer followed by the character s, m, h, D, W, M, or Y, indicating seconds, minutes, hours, days, weeks, months, or
  249. years respectively, or a number of these concatenated. For example, 32m means 32 minutes, and 3W2D10h7s means 3 weeks, 2 days, 10 hours, and 7 seconds. In this context, a
  250. month means 30 days, a year is 365 days, and a day is always 86400 seconds.
  251.  
  252. rdiff-backup cannot remove-older-than and back up or restore in a single session. In order to both backup a directory and remove old files in it, you must run rdiff-backup
  253. twice.
  254.  
  255. 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
  256. tell you if --force is required).
  257.  
  258. 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
  259. --remove-older-than 10D today, no trace of that file would remain. Finally, file selection options such as --include and --exclude don't affect --remove-older-than.
  260.  
  261. --restrict path
  262. Require that all file access be inside the given path. This switch, and the following two, are intended to be used with the --server switch to provide a bit more protection
  263. when doing automated remote backups. They 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
  264. run with --restrict-read-only.
  265.  
  266. --restrict-read-only path
  267. Like --restrict, but also reject all write requests.
  268.  
  269. --restrict-update-only path
  270. Like --restrict, but only allow writes as part of an incremental backup. Requests for other types of writes (for instance, deleting path) will be rejected.
  271.  
  272. --server
  273. Enter server mode (not to be invoked directly, but instead used by another rdiff-backup process on a remote computer).
  274.  
  275. --ssh-no-compression
  276. When running ssh, do not use the -C option to enable compression. --ssh-no-compression is ignored if you specify a new schema using --remote-schema.
  277.  
  278. --tempdir path
  279. 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 di‐
  280. rectory. See the documentation of the Python tempfile module for more information.
  281.  
  282. --terminal-verbosity [0-9]
  283. Select which messages will be displayed to the terminal. If missing the level defaults to the verbosity level.
  284.  
  285. --test-server
  286. Test for the presence of a compatible rdiff-backup server as specified in the following host::filename argument(s). The filename section will be ignored.
  287.  
  288. --use-compatible-timestamps
  289. 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;
  290. rdiff-backup supports the intermingling of different timestamp formats. This option is enabled by default on platforms which require that the colon be escaped.
  291.  
  292. --user-mapping-file filename
  293. Map user names and ids according to the user mapping file filename. See the USERS AND GROUPS section for more information.
  294.  
  295. -v[0-9], --verbosity [0-9]
  296. 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.
  297.  
  298. --verify
  299. This is short for --verify-at-time now
  300.  
  301. --verify-at-time now
  302. 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.
  303.  
  304. -V, --version
  305. Print the current version and exit
  306.  
  307. ENVIRONMENT
  308. RDIFF_BACKUP_VERBOSITY=[0-9]
  309. Sets the default verbosity for log file and terminal, can be overwritten by the corresponding options "-v/--verbosity" and "--terminal-verbosity".
  310.  
  311. RESTORING
  312. There are two ways to tell rdiff-backup to restore a file or directory. Firstly, you can run rdiff-backup on a mirror file and use the -r or --restore-as-of options. Secondly, you
  313. can run it on an increment file.
  314.  
  315. For example, suppose in the past you have run:
  316.  
  317. rdiff-backup /usr /usr.backup
  318.  
  319. to back up the /usr directory into the /usr.backup directory, and now want a copy of the /usr/local directory the way it was 3 days ago placed at /usr/local.old.
  320.  
  321. One way to do this is to run:
  322.  
  323. rdiff-backup -r 3D /usr.backup/local /usr/local.old
  324.  
  325. where above the "3D" means 3 days (for other ways to specify the time, see the TIME FORMATS section). The /usr.backup/local directory was selected, because that is the directory con‐
  326. taining the current version of /usr/local.
  327.  
  328. Note that the option to --restore-as-of always specifies an exact time. (So "3D" refers to the instant 72 hours before the present.) If there was no backup made at that time, rdiff-
  329. backup restores the state recorded for the previous backup. For instance, in the above case, if "3D" is used, and there are only backups from 2 days and 4 days ago, /usr/local as it
  330. was 4 days ago will be restored.
  331.  
  332. The second way to restore files involves finding the corresponding increment file. It would be in the /backup/rdiff-backup-data/increments/usr directory, and its name would be some‐
  333. thing like "local.2002-11-09T12:43:53-04:00.dir" where the time indicates it is from 3 days ago. Note that the increment files all end in ".diff", ".snapshot", ".dir", or ".missing",
  334. where ".missing" just means that the file didn't exist at that time (finally, some of these may be gzip-compressed, and have an extra ".gz" to indicate this). Then running:
  335.  
  336. rdiff-backup /backup/rdiff-backup-data/increments/usr/local.<time>.dir /usr/local.old
  337.  
  338. would also restore the file as desired.
  339.  
  340. If you are not sure exactly which version of a file you need, it is probably easiest to either restore from the increments files as described immediately above, or to see which incre‐
  341. ments are available with -l/--list-increments, and then specify exact times into -r/--restore-as-of.
  342.  
  343. TIME FORMATS
  344. rdiff-backup uses time strings in two places. Firstly, all of the increment files rdiff-backup creates will have the time in their filenames in the w3 datetime format as described in
  345. a w3 note at https://www.w3.org/TR/NOTE-datetime. Basically they look like "2001-07-15T04:09:38-07:00", which means what it looks like. The "-07:00" section means the time zone is 7
  346. hours behind UTC.
  347.  
  348. Secondly, the -r, --restore-as-of, and --remove-older-than options take a time string, which can be given in any of several formats:
  349.  
  350. 1. the string "now" (refers to the current time)
  351.  
  352. 2. a sequences of digits, like "123456890" (indicating the time in seconds after the epoch)
  353.  
  354. 3. A string like "2002-01-25T07:00:00+02:00" in datetime format
  355.  
  356. 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
  357. 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
  358. 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.
  359.  
  360. 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 in‐
  361. stance, "2002/3/5", "03-05-2002", and "2002-3-05" all mean March 5th, 2002.
  362.  
  363. 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
  364. 3rd newest increment.
  365.  
  366. REMOTE OPERATION
  367. 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
  368. pipe, rdiff-backup first splits the filename into host_info::pathname. It then substitutes host_info into the remote schema, and runs the resulting command, reading its input and out‐
  369. put.
  370.  
  371. The default remote schema is 'ssh -C %s rdiff-backup --server' where host_info is substituted for '%s'. So if the host_info is user@host.net, then rdiff-backup runs 'ssh user@host.net
  372. rdiff-backup --server'. Using --remote-schema, rdiff-backup can invoke an arbitrary command in order to open up a remote pipe. For instance,
  373. rdiff-backup --remote-schema 'cd /usr; %s' foo 'rdiff-backup --server'::bar
  374. is basically equivalent to (but slower than)
  375. rdiff-backup foo /usr/bar
  376.  
  377. Concerning quoting, if for some reason you need to put two consecutive colons in the host_info section of a host_info::pathname argument, or in the pathname of a local file, you can
  378. quote one of them by prepending a backslash. So in 'a\::b::c', host_info is 'a::b' and the pathname is 'c'. Similarly, if you want to refer to a local file whose filename contains
  379. two consecutive colons, like 'strange::file', you'll have to quote one of the colons as in 'strange\::file'. Because the backslash is a quote character in these circumstances, it too
  380. must be quoted to get a literal backslash, so 'foo\::\\bar' evaluates to 'foo::\bar'. To make things more complicated, because the backslash is also a common shell quoting character,
  381. you may need to type in '\\\\' at the shell prompt to get a literal backslash (if it makes you feel better, I had to type in 8 backslashes to get that in this man page...). And fi‐
  382. nally, to include a literal % in the string specified by --remote-schema, quote it with another %, as in %%.
  383.  
  384. Although ssh itself may be secure, using rdiff-backup in the default way presents some security risks. For instance if the server is run as root, then an attacker who compromised the
  385. client could then use rdiff-backup to overwrite arbitrary server files by "backing up" over them. Such a setup can be made more secure by using the sshd configuration option com‐
  386. mand="rdiff-backup --server" possibly along with the --restrict* options to rdiff-backup. For more information, see the web page, the wiki, and the entries for the --restrict* options
  387. on this man page.
  388.  
  389. FILE SELECTION
  390. 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 op‐
  391. tions. 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
  392. the examples.html file included in the package, or on the web at https://rdiff-backup.net/docs/examples.html
  393.  
  394. rdiff-backup's selection system was originally inspired by rsync(1), but there are many differences. (For instance, trailing backslashes have no special significance.)
  395.  
  396. The file selection system comprises a number of file selection conditions, which are set using one of the following command line options: --exclude, --exclude-filelist, --exclude-de‐
  397. vice-files, --exclude-fifos, --exclude-sockets, --exclude-symbolic-links, --exclude-globbing-filelist, --exclude-globbing-filelist-stdin, --exclude-filelist-stdin, --exclude-regexp,
  398. --exclude-special-files, --include, --include-filelist, --include-globbing-filelist, --include-globbing-filelist-stdin, --include-filelist-stdin, and --include-regexp. Each file se‐
  399. lection condition either matches or doesn't match a given file. A given file is excluded by the file selection system exactly when the first matching file selection condition speci‐
  400. fies that the file be excluded; otherwise the file is included. When backing up, if a file is excluded, rdiff-backup acts as if that file does not exist in the source directory. When
  401. restoring, an excluded file is considered not to exist in either the source or target directories.
  402.  
  403. For instance,
  404.  
  405. rdiff-backup --include /usr --exclude /usr /usr /backup
  406.  
  407. is exactly the same as
  408.  
  409. rdiff-backup /usr /backup
  410.  
  411. because the include and exclude directives match exactly the same files, and the --include comes first, giving it precedence. Similarly,
  412.  
  413. rdiff-backup --include /usr/local/bin --exclude /usr/local /usr /backup
  414.  
  415. would backup the /usr/local/bin directory (and its contents), but not /usr/local/doc.
  416.  
  417. The include, exclude, include-globbing-filelist, and exclude-globbing-filelist options accept extended shell globbing patterns. These patterns can contain the special patterns *, **,
  418. ?, and [...]. As in a normal shell, * can be expanded to any string of characters not containing "/", ? expands to any character except "/", and [...] expands to a single character
  419. of those characters specified (ranges are acceptable). The new special pattern, **, expands to any string of characters whether or not it contains "/". Furthermore, if the pattern
  420. starts with "ignorecase:" (case insensitive), then this prefix will be removed and any character in the string can be replaced with an upper- or lowercase version of itself.
  421.  
  422. If you need to match filenames which contain the above globbing characters, they may be escaped using a backslash "\". The backslash will only escape the character following it so for
  423. ** you will need to use "\*\*" to avoid escaping it to the * globbing character.
  424.  
  425. Remember that you may need to quote these characters when typing them into a shell, so the shell does not interpret the globbing patterns before rdiff-backup sees them.
  426.  
  427. The --exclude pattern option matches a file iff:
  428.  
  429. 1. pattern can be expanded into the file's filename, or
  430.  
  431. 2. the file is inside a directory matched by the option.
  432.  
  433. Conversely, --include pattern matches a file iff:
  434.  
  435. 1. pattern can be expanded into the file's filename,
  436.  
  437. 2. the file is inside a directory matched by the option, or
  438.  
  439. 3. the file is a directory which contains a file matched by the option.
  440.  
  441. For example,
  442.  
  443. --exclude /usr/local
  444.  
  445. matches /usr/local, /usr/local/lib, and /usr/local/lib/netscape. It is the same as --exclude /usr/local --exclude '/usr/local/**'.
  446.  
  447. --include /usr/local
  448.  
  449. specifies that /usr, /usr/local, /usr/local/lib, and /usr/local/lib/netscape (but not /usr/doc) all be backed up. Thus you don't have to worry about including parent directories to
  450. make sure that included subdirectories have somewhere to go. Finally,
  451.  
  452. --include ignorecase:'/usr/[a-z0-9]foo/*/**.py'
  453.  
  454. would match a file like /usR/5fOO/hello/there/world.py. If it did match anything, it would also match /usr. If there is no existing file that the given pattern can be expanded into,
  455. the option will not match /usr.
  456.  
  457. The --include-filelist, --exclude-filelist, --include-filelist-stdin, and --exclude-filelist-stdin options also introduce file selection conditions. They direct rdiff-backup to read
  458. in a file, each line of which is a file specification, and to include or exclude the matching files. Lines are separated by newlines or nulls, depending on whether the --null-separa‐
  459. tor switch was given. Each line in a filelist is interpreted similarly to the way extended shell patterns are, with a few exceptions:
  460.  
  461. 1. Globbing patterns like *, **, ?, and [...] are not expanded.
  462.  
  463. 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.
  464.  
  465. 3. Lines starting with "+ " are interpreted as include directives, even if found in a filelist referenced by --exclude-filelist. Similarly, lines starting with "- " exclude files
  466. even if they are found within an include filelist.
  467.  
  468. For example, if the file "list.txt" contains the lines:
  469.  
  470. /usr/local
  471. - /usr/local/doc
  472. /usr/local/bin
  473. + /var
  474. - /var
  475.  
  476. then "--include-filelist list.txt" would include /usr, /usr/local, and /usr/local/bin. It would exclude /usr/local/doc, /usr/local/doc/python, etc. It neither excludes nor includes
  477. /usr/local/man, leaving the fate of this directory to the next specification condition. Finally, it is undefined what happens with /var. A single file list should not contain con‐
  478. flicting file specifications.
  479.  
  480. The --include-globbing-filelist and --exclude-globbing-filelist options also specify filelists, but each line in the filelist will be interpreted as a globbing pattern the way --in‐
  481. clude and --exclude options are interpreted (although "+ " and "- " prefixing is still allowed). For instance, if the file "globbing-list.txt" contains the lines:
  482.  
  483. dir/foo
  484. + dir/bar
  485. - **
  486.  
  487. Then "--include-globbing-filelist globbing-list.txt" would be exactly the same as specifying "--include dir/foo --include dir/bar --exclude **" on the command line.
  488.  
  489. Finally, the --include-regexp and --exclude-regexp allow files to be included and excluded if their filenames match a python regular expression. Regular expression syntax is too com‐
  490. plicated to explain here, but is covered in Python's library reference. Unlike the --include and --exclude options, the regular expression options don't match files containing or con‐
  491. tained in matched files. So for instance
  492.  
  493. --include '[0-9]{7}(?!foo)'
  494.  
  495. matches any files whose full pathnames contain 7 consecutive digits which aren't followed by 'foo'. However, it wouldn't match /home even if /home/ben/1234567 existed.
  496.  
  497. USERS AND GROUPS
  498. 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-
  499. backup maps ownership on the source to the destination (or vice-versa, in the case of restoring):
  500.  
  501. 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
  502. change.
  503.  
  504. 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.
  505.  
  506. 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
  507. has a bad user or group name.
  508.  
  509. 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,
  510. 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.
  511.  
  512. The user and group mapping files both have the same form:
  513.  
  514. old_name_or_id1:new_name_or_id1
  515. old_name_or_id2:new_name_or_id2
  516. <etc>
  517.  
  518. Each line should contain a name or id, followed by a colon ":", followed by another name or id. If a name or id is not listed, they are treated in the default way described above.
  519.  
  520. When restoring, the above behavior is also followed, but note that the original source user/group information will be the input, not the already mapped user/group information present
  521. in the backup repository. For instance, suppose you have mapped all the files owned by alice in the source so that they are owned by ben in the repository, and now you want to re‐
  522. store, making sure the files owned originally by alice are still owned by alice. In this case there is no need to use any of the mapping options. However, if you wanted to restore
  523. the files so that the files originally owned by alice on the source are now owned by ben, you would have to use the mapping options, even though you just want the unames of the reposi‐
  524. tory's files preserved in the restored files.
  525.  
  526. STATISTICS
  527. Every session rdiff-backup saves various statistics into two files, the session statistics file at rdiff-backup-data/session_statistics.<time>.data and the directory statistics file at
  528. rdiff-backup-data/directory_statistics.<time>.data. They are both text files and contain similar information: how many files changed, how many were deleted, the total size of incre‐
  529. ment files created, etc. However, the session statistics file is intended to be very readable and only describes the session as a whole. The directory statistics file is more compact
  530. (and slightly less readable) but describes every directory backed up. It also may be compressed to save space.
  531.  
  532. Statistics-related options include --print-statistics and --null-separator.
  533.  
  534. Also, 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. Gener‐
  535. ally 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.
  536.  
  537. The log file is not compressed and can become quite large if rdiff-backup is run with high verbosity.
  538.  
  539. EXIT STATUS
  540. If rdiff-backup finishes successfully, the exit status will be 0. If there is an unrecoverable (critical) error, it will be non-zero (usually 1, but don't depend on this specific
  541. value). When setting up rdiff-backup to run automatically (as from cron(8) or similar) it is probably a good idea to check the exit code.
  542.  
  543. BUGS
  544. The gzip library in versions 2.2 and earlier of python (but fixed in 2.3a1) has trouble producing files over 2GB in length. This bug will prevent rdiff-backup from producing large
  545. compressed increments (snapshots or diffs). A workaround is to disable compression for large incompressible files.
  546.  
  547. AUTHOR
  548. Ben Escoto <ben@emerose.org>
  549.  
  550. Feel free to ask me questions or send me bug reports, but you may want to see the web page, mentioned below, first.
  551.  
  552. SEE ALSO
  553. python(1), rdiff(1), rsync(1), ssh(1). The main rdiff-backup web page is at https://rdiff-backup.net/. It has more information, links to the mailing list and CVS, etc.
  554.  
  555. Version 2.0.5 March 2022 RDIFF-BACKUP(1)
  556.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement