I quote here in full the page that contains the examples published on the official website of the project rdiff-backup. I do not exclude the ability to provide its gradual translation, in the coming days, weather permitting.

rdiff-backup examples

Sections

Backing up

  • Simplest case-backup local directory foo to local directory bar. bars will end up copy of foo, except it will Contain the directory foo / rdiff-backup-data, 'which will allow rdiff-backup to restore previous states.
    rdiff-backup foo bar
  • Simple houses remote-backup directory / some / local-dir to the directory / whatever / remote-dir on the machine hostname.net. It uses ssh Necessary to open the pipe to the remote copy of rdiff-backup. Just like the above except one directory is on a remote computer.
    rdiff-backup /some/local-dir hostname.net::/whatever/remote-dir
  • This time the source directory is remote and the destination is local. Also, we have specified the username on the remote host (by default ssh will attempt to log you in with the username you have examination on the local host).
    rdiff-backup user@hostname.net::/remote-dir local-dir
  • It is even possible for Both the source and destination directories to be on other machines. Also below we have added the-v5 switch for Greater verbosity (verbosity settings go from 0 to 9, with 3 as the default), and the-print-statistics switch so some statistics will not be displayed at the end (even without this switch, the statistics will still be saved in the rdiff-backup-data directory).
    rdiff-backup -v5 --print-statistics user1@host1::/source-dir user2@host2::/dest-dir

Restoring

  • Suppose we have discussed earlier run rdiff-backup foo bar, With Both foo and bar local. We accidentally deleted foo / dir and now want to restore it from bar / dir.
    cp -a bar/dir foo/dir That's right, since rdiff-backup makes a mirror, we can retrieve files using standard commands like cp.
  • For the rest of the examples in the section, we will assume That the user has backed up with the command rdiff-backup local-dir host.net :: / remote-dir. Of course, in All These examples it would be 'equally possible to have the source being remote and the backup directory local.In this case we can not use cp to copying host.net :: remote-dir/file to local-dir / Files Because They Are on different machines. We can get rdiff-backup to restore the current version of that file using Either of These ::
    rdiff-backup --restore-as-of now host.net::/remote-dir/file local-dir/file
    rdiff-backup -r now host.net::/remote-dir/file local-dir/file
    rdiff-backup --restore-as-of now host.net::/remote-dir/file local-dir/file
    rdiff-backup -r now host.net::/remote-dir/file local-dir/file
    The-restore-as-of (or-r for short) switch tells rdiff-backup to restore instead of backup, and the Indicates the current time now option.
  • But the main advantage of rdiff-backup is it That Keeps version history. This command restores host.net :: / remote-dir/file as it was 10 days ago into a new location / tmp / file.
    rdiff-backup -r 10D host.net::/remote-dir/file /tmp/file Other acceptable time strings include 5m4s (5 minutes and 4 seconds) and 03.05.2002 (March 5th, 2002). For more information, see the TIME FORMATS section of the manual page.
  • Finally, we can use rdiff-backup to restore from an increment file directory. Increment files are stored in host.net :: / remote-dir/rdiff-backup-data/increments and hold the previous versions of changed files. If you Directly Specify one:
    rdiff-backup host.net::/remote-dir/rdiff-backup-data/increments/file.2003-03-05T12:21:41-07:00.diff.gz local-dir/file rdiff-backup will tell That from the filename it is an increment files rdiff-backup and restore Thus enter mode. Above the restored version is written to local-dir/file.

Deleting files older

Although rdiff-backup tries to save space by only storing files Differences, Eventually may run out space in the destination directory. rdiff-backup's-remove-older-than mode can be used to delete older increments.

This section assumes That rdiff-backup has-been used in the past to back up to host.net :: / remote-dir, but all commands would work locally too, if the hostname Were ommitted.

  • Deletes all commands this information Concerning Which files have not Been current versions for 2 weeks:
    rdiff-backup --remove-older-than 2W host.net::/remote-dir Notes That Which Has not changed an existing file for a year will still be preserved. But a file was deleted 15 days ago Which can not be restored after this command is run.
  • As When restoring, there are a variety of ways to Specify the time. The 20B below tells rdiff-backup to only preserve information from the last 20 rdiff-backup sessions. (NNB syntax is only available in versions after 0.13.1.)
    rdiff-backup --remove-older-than 20B host.net::/remote-dir

File selection with include / exclude options

Sometimes you do not want to back up all files. Various-The-include and exclude options can be used to select Exactly Which files to back up. See the man page for a list of all the options and Their definitions.

  • In this example we exclude / mnt / backup to avoid an endless loop.
    rdiff-backup --exclude /mnt/backup / /mnt/backup (Actually rdiff-backup can automatically detect simple loops like the one above.) This is just an example, in reality it would be important to exclude / proc as well.
  • This example is more realistic. We have Excluded / proc, / tmp, and / mnt. / Proc particolare Should never be backed up. Also, the source directory happens to be remote.
    rdiff-backup --exclude /tmp --exclude /mnt --exclude /proc user@host.net::/ /backup/host.net
  • Multiple include and exclude options take precedence in the order They Are Given. The following command would back up / usr / local / bin but not / usr / bin.
    rdiff-backup --include /usr/local --exclude /usr / host.net::/backup
  • rdiff-backup uses rsync-like wildcards, where ** matches any path and * matches any path without a / in it. Thus this command:
    rdiff-backup --include /usr/local --include /var --exclude '**' / /backup backs up only the / usr / local and / var directories. The single quotes "are not part of rdiff-backup and are only used Because many shells will expand **.
  • Here is to more complicated example:
    rdiff-backup --include '**txt' --exclude /usr/local/games --include /usr/local --exclude /usr --exclude /backup --exclude /proc / /backup The above command will back up any files ending in txt, even / usr / local / games / tennis / scores.txt Because That includes Highest has precedence. The contents of the directory / usr / local / bin will get backed up, but not / usr / share or / usr / local / games / tennis.
  • Also rdiff-backup can accept a list of files to be backed up. If the file include-list contains These two lines:
    /var
    /usr/bin/gzip
    /var
    /usr/bin/gzip
    Then this command:

    rdiff-backup --include-filelist include-list --exclude '**' / /backup
    would only back up the files / var, / usr, / usr / bin and / usr / bin / gzip, but not / var / log or / usr / bin / gunzip. That this differs from the known-include option, since-include / var Also would match / var / log.
  • Both The Same file list can include and exclude files. If we create a file-list includes Called That These lines contains:
    **txt
    - /usr/local/games
    /usr/local
    - /usr
    - /backup
    - /proc

    Then The following command will do Exactly The Same Thing as the complicated example two above.
    rdiff-backup --include-globbing-filelist include-list / /backup
    Above we have used-include-globbing-filelist instead of-include-filelist know That the lines would be Interpreted as if They Were specified on the command line. Otherwise, for instance, ** txt would be Considered the name of a file, not a globbing string.

Getting information about the backup directory

The following examples assume That you have run rdiff-backup-dir out-dir in the past.

  • This command finds all files new or old frobniz Which Contain the string.
    find out-dir -name '*frobniz*'
    rdiff-backup Does not obscure the names of files at all, I Often using traditional tools work well.
  • Either of These equivalent commands lists the times of the available versions of the files out-dir/file. It may be useful if you need to restore an older version of in-dir/file but not are sure which one.
    rdiff-backup --list-increments out-dir/file
    rdiff-backup -l out-dir/file
  • The following command lists all the files under out-dir/subdir Which has changed in the last 5 days.
    rdiff-backup --list-changed-since 5D out-dir/subdir
  • This command lists all the files present in out-dir/subdir That Were 5 days ago. This includes files That have not changed recently as well as Those That Have Been deleted in the last 5 days.
    rdiff-backup --list-at-time 5D out-dir/subdir
  • The first command below Compares the files in current dir-out (Which is on a remote computer) with the files in in-dir, displaying which ones have changed. The second command is similar to but Compares in-dir out-dir as it was 2 weeks in August
    rdiff-backup --compare in-dir user@host::out-dir
    rdiff-backup --compare-at-time 2W in-dir user@host::out-dir
  • rdiff-backup writes one statistics file per session out-dir/rdiff-backup-data to the directory. An average of the files can not be displayed using the-calculate-average option and Specifying the files to use statistics.
    rdiff-backup --calculate-average out-dir/rdiff-backup-data/session_statistics*

Miscellaneous other commands

  • If you are HAVING problems connecting to a remote host, the-test-server command may be useful. This command simply verifies That there is a working rdiff-backup server on the remote side.
    rdiff-backup --test-server hostname.net::/ignored
Source: http://rdiff-backup.nongnu.org
Share this content:
  • del.icio.us
  • Google Bookmarks
  • Digg
  • Facebook
  • Technorati
  • MySpace
  • Twitter