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
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
rsync --progress -avz sources user@remote:
rsync --progress -avz user@remote:sources .
cp or scp
cp"
idea. If you put a trailing slash on any path name (local or remote), it
takes it as path/*. In the following commands, think what cp
would do if you appended a * wherever there is a trailing /.
(wrong) rsync -avz sources/ user@remote:
(wrong) rsync -avzP user@remote:sources sources
(right) rsync -avzP user@remote:sources/ sources
(right) rsync -avzP user@remote:sources .
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
nowin the above command can be something like3Mor5Dor 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.
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
-R defaults to "."
-g and -P must be relative to -R.
-P pattern is excluded. If
there are no -g patterns, the entire -R is considered, otherwise,
only files matching the -g patterns are considered.
dar -l dar-archive-base-name
.1.dar at the end!
-as lists only files actually saved in a differential backup
dar -x dar-archive-base-name
-k and -r are useful if you want to play safe; dar -h for
details
-l and -x, -I gets you just the files you want, without
worrying about the full path.
-y), encrypted (-K:), and offline (everything a
mirror isn't!)
-A old_dar_file)
-s), pausing (-p) to let you burn each
slice to a CD. Make backups with very little free space!
-C) a "catalog" of offline archives and manage the
catalogs
/usr/share/doc
dar_manager with -s.
kdar GUI supports some of dar's options, not all. Not very useful
except to show you a graphical tree of an archive file and let you
interactively diff/test/restore one/some files.
~/.darrc
create:
# I care more about preserving ctime than atime
-aa
# bzip2 compress
-y
# I dont care about extended attributes in user...
-u
# ...and root namespaces
-U
# minimum 512 bytes in order to compress a file
-m 256
# ignore case for following flags
-an
# do not compress following extensions, case insensitive due to above
-Z "*.avi"
-Z "*.bz2"
# -Z "*.gif"
-Z "*.gz"
-Z "*.jar"
-Z "*.jpeg"
-Z "*.jpg"
-Z "*.mov"
-Z "*.mp3"
-Z "*.mpg"
# -Z "*.png"
-Z "*.tgz"
-Z "*.zip"
# set case sensitivity back to default
-acase
extract:
# use -O only for ordinary users' ~/.darrc, not for root
-O
-u
-U
-B lets you specify any options, but is best used to specify an
include/exclude list (example below):
-g /var/www
-g /var/spool/cron
-g /var/named
--prune /var/mailman/archives
-g /var/mailman
dar_manager -C my_dmd (once only)
dar_manager -B my_dmd -A 2006-07-01-full_catalog (for each archive)
dar_manager -B my_dmd -r files-to-restore
Unison has a nice GUI. Use it.
ignore = Name {CVS,*.cmo}
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
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