Tips for backup, mirroring, and synchronisation


This document has the following sections:

    Tips for backup, mirroring, and synchronisation
        Temporary backups
                    Features and uses
                    Downsides
        Plain mirror, local or remote
                    Features and uses
                    Downsides
        better than rsync
                    Features and uses
                    Downsides
        real backups
                    Features and uses
                    Downsides
                    Additional notes
        Synchronisation -- when files can change on both sides
                    Features and uses
                    Sample profile 1
                    Sample profile 2


Temporary backups

tar uvf rescue.tar file1 file2

tar xvf rescue.tar file-you-want

tar tvf rescue.tar file-you-want | nl
tar xvf rescue.tar --occurrence=7 file-you-want

Features and uses

Downsides


Plain mirror, local or remote

rsync --progress -avz sources user@remote:

rsync --progress -avz user@remote:sources .

Features and uses

Downsides


better than rsync

http://www.nongnu.org/rdiff-backup/examples.html

rdiff-backup --include-globbing-filelist incl.lst / /target-dir

Target can be user@host::path (note the double colon).

rdiff-backup -r now user@host::/bigfs/rd-b.data/home/sitaram/bin bin

now in the above command can be something like 3M or 5D or date/time etc.

rdiff-backup --remove-older-than 3M /bigfs/rd-b.data

A sample incl.lst looks like:

    /var/spool/cron
    - /usr/local/share/vim
    /usr/local
    - /home/sitaram/.mozilla/firefox/44kffhfm.default/Cache
    /home/sitaram/.mozilla
    - **
IMPORTANT: Paths in the include/exclude list should start with either **/ or the source directory name. Using ./ won't work unless the source directory was given as ".".

Files are matched against the patterns in the order given; the first match stops further checking. Hence the order of the cache line and the mozilla line, for example.

Also, the default is to "include", so we have an ultra-wildcard exclude at the end.

Features and uses

Downsides


real backups

dar -h gives you a pretty good summary of the options.

dar -c /bigfs/dar-data -R sources -g dir-to-save -P dir-to-save/subdir-not-to-save

dar -l dar-archive-base-name

dar -x dar-archive-base-name

For both -l and -x, -I gets you just the files you want, without worrying about the full path.

Features and uses

Downsides

Additional notes


Synchronisation -- when files can change on both sides

Unison has a nice GUI. Use it.

Features and uses

Sample profile 1

    label = sync the a780 flash disk
    include default
    perms = 0o0400
    pretendwin = true
    root = /home/sitaram/a780-backup/
    root = /mnt/removable
    
My default.prf is:

    # Unison preferences file
    height = 40
    diff = gvim -d
    
Sample profile 2

Note that the order of ignore (exclude) and ignorenot (include) does not matter.

    label = RC files and other settings

    include default

    root = /home/sitaram
    root = ssh://sitaram@remote.host

    # "ignore = Path something/*" works, but "ignore = Path *" doesn't
    # (this is documented!)
    ignore = Path ?*
    ignore = Path .*

    ignorenot = Path .*bashrc
    ignorenot = Path .darrc
    ignorenot = Path .vimrc
    ignorenot = Path .sunrise
    ignore    = Path .sunrise/cache