rdiff-backup-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[rdiff-backup-users] backup-server solution, maybe feature ideas


From: Christian Thaeter
Subject: [rdiff-backup-users] backup-server solution, maybe feature ideas
Date: Thu, 11 Aug 2005 19:30:46 +0200
User-agent: Debian Thunderbird 1.0.2 (X11/20050602)

Attached is a small shell-script to implement a central backup-server,
not very well documented, but works for me ;).

The reason i'll post it here is:
 first: maybe someone finds it useful and
 second: its quite kludgey some of the things it does might be
implemented in rdiff-backup instead having workarounds.


These are:
 --check-destination dir should be combineable with other options and
ensure that the backup dir is consistent before going any further and
dont exit with a "Fatal Error: Destination dir ... does not need checking".

 --remove-older-than ... i would like to have a --move-older-than <age>
<dir> where older increments are moved to some archive and can be burned
to CD. Some adaptive --merge-older-than which merges increments might be
nice too (if not too expensive) making it possible for example that one
can keep daily backups for the last month, weekly for the last half year
and anually backups for anything older (this is just an idea, I didnt
thought to carefully about that).

  In my script it takes 2 backup cycles to backup new things when the
include lists have changed. There is no way to first grab the the
include lists only (just --include them and exclude anything else counts
as massive file removal) a --no-deletes or similar option would be nice.

  These user defined global and local include lists could me make a fine
 feature for rsync-backup too.


        Cheers Christian
#!/bin/bash

# Drop this file into /etc/cron.daily/

#Server Configuration:
# /etc/rdiff-backup.conf
#  BACKUPDIR=local location where to place the backups
#  SSH_KEY=path to a passwortless ssh key which will be used to login into 
other machines
#  MAXAGE=default age for backups
#  LOGCMD= ususally "logger -p user.notice -t rdiff-backup[$$]"
#
# /etc/rdiff-backup.hosts 
# lines containing:
#  <name> <location> <age>
#   name is the name appended to $BACKUPDIR and use to identify the backup
#   location is a rdiff-backup format description of the source location
#   age is optional and gives the time for how long backups are kept else 
$MAXAGE is taken as default
#   a leading # disables the line (comment)
#
# /etc/rdiff-backup.inc.$name 
#  rdiff-backup formatted include-globlist used when backung up $name

#Client Configuration:
# following paths are searched for global include-globlists
#  /rdiff-backup.inc
#  /.rdiff-backup.inc
#  /etc/rdiff-backup.inc
#
# following parts are searched for local include-globlists (apply only to 
subdirs)
#  /home/*/.rdiff-backup.inc
#  /home/*/*/.rdiff-backup.inc

if test -f /etc/rdiff-backup.conf; then
        source /etc/rdiff-backup.conf
else
        echo "missing /etc/rdiff-backup.conf"
        exit 125
fi

eval $(ssh-agent)
ssh-add $SSH_KEY

cat /etc/rdiff-backup.hosts |\
while read name location maxage; do
        test "${name:0:1}" = '#' && continue 

        echo "Backing up $name from $location" | $LOGCMD

        TMP=$(tempfile)

        nice rdiff-backup --check-destination-dir $BACKUPDIR/$name/ 2>&1 |\
                $LOGCMD

        nice rdiff-backup --remove-older-than ${maxage:-$MAXAGE} --force 
$BACKUPDIR/$name/ 2>&1 |\
                $LOGCMD

        (
                echo "- $BACKUPDIR"
                echo "+ /rdiff-backup.inc"
                echo "+ /.rdiff-backup.inc"
                echo "+ /etc/rdiff-backup.inc"
                echo "+ /home/*/.rdiff-backup.inc"
                echo "+ /home/*/*/.rdiff-backup.inc"

                test -f "/etc/rdiff-backup.inc.$name" && cat 
"/etc/rdiff-backup.inc.$name"
                test -f "$BACKUPDIR/$name/rdiff-backup.inc" && cat 
"$BACKUPDIR/$name/rdiff-backup.inc"
                test -f "$BACKUPDIR/$name/.rdiff-backup.inc" && cat 
"$BACKUPDIR/$name/.rdiff-backup.inc"
                test -f "$BACKUPDIR/$name/etc/rdiff-backup.inc" && cat 
"$BACKUPDIR/$name/etc/rdiff-backup.inc"
                for i in $BACKUPDIR/$name/home/*/.rdiff-backup.inc; do
                        test "$i" = "$BACKUPDIR/$name/home/*/.rdiff-backup.inc" 
&& break
                        dirname="$(dirname $i)"
                        dirname="${dirname#$BACKUPDIR/$name}"
                        sed -e 's|^\([+-] \)\?\(.\+\)$|\1'${dirname}'/\2|' -e 
'/^$/d' -e '/\.\./d' <$i
                done
                for i in $BACKUPDIR/$name/home/*/*/.rdiff-backup.inc; do
                        test "$i" = 
"$BACKUPDIR/$name/home/*/*/.rdiff-backup.inc" && break
                        dirname="$(dirname $i)"
                        dirname="${dirname#$BACKUPDIR/$name}"
                        sed -e 's|^\([+-] \)\?\(.\+\)$|\1'${dirname}'/\2|' -e 
'/^$/d' -e '/\.\./d' <$i
                done
        ) >$TMP

        nice rdiff-backup -b --include-globbing-filelist $TMP --exclude '*' 
$location $BACKUPDIR/$name/ 2>&1 |\
                $LOGCMD

        nice rdiff-backup --list-increments $BACKUPDIR/$name/ 2>&1 |\
                $LOGCMD

        rm $TMP
done

eval $(ssh-agent -k)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]