diff options
author | rhatto <rhatto@370017ae-e619-0410-ac65-c121f96126d4> | 2006-09-20 00:41:18 +0000 |
---|---|---|
committer | rhatto <rhatto@370017ae-e619-0410-ac65-c121f96126d4> | 2006-09-20 00:41:18 +0000 |
commit | 8d01396f60619d873e11d6c59aeeafb974a204e4 (patch) | |
tree | 6d07c149b92b7c90cfa03a6999f1f56f62d4cf96 /backupninja | |
parent | 51c42871d1c5fac7c55112c0a1d65f2d022f1e5e (diff) | |
download | slackbuilds-8d01396f60619d873e11d6c59aeeafb974a204e4.tar.gz slackbuilds-8d01396f60619d873e11d6c59aeeafb974a204e4.tar.bz2 |
backupninja: added pull handler; updated rub handler
git-svn-id: svn+slack://slack.fluxo.info/var/svn/slackbuilds@239 370017ae-e619-0410-ac65-c121f96126d4
Diffstat (limited to 'backupninja')
-rwxr-xr-x | backupninja/backupninja.SlackBuild | 3 | ||||
-rwxr-xr-x | backupninja/pull | 93 | ||||
-rwxr-xr-x | backupninja/rub | 22 |
3 files changed, 106 insertions, 12 deletions
diff --git a/backupninja/backupninja.SlackBuild b/backupninja/backupninja.SlackBuild index 9a2a81bd..4a660987 100755 --- a/backupninja/backupninja.SlackBuild +++ b/backupninja/backupninja.SlackBuild @@ -18,7 +18,7 @@ fi PACKAGE="backupninja" ARCH="noarch" VERSION=${VERSION:=0.9.3} -BUILD=${BUILD:=20rha} +BUILD=${BUILD:=21rha} SRC_DIR=${SRC:=$CWD} TMP=${TMP:=/tmp} REPOS=${REPOS:=$TMP} @@ -65,6 +65,7 @@ make make DESTDIR=$TMP/package-$PACKAGE install cp $CWD/rub $TMP/package-$PACKAGE/usr/share/$PACKAGE/ +cp $CWD/pull $TMP/package-$PACKAGE/usr/share/$PACKAGE/ rm -rf $TMP/package-$PACKAGE/etc/cron.d mkdir $TMP/package-$PACKAGE/etc/cron.hourly cp $CWD/backupninja.cron $TMP/package-$PACKAGE/etc/cron.hourly/backupninja diff --git a/backupninja/pull b/backupninja/pull new file mode 100755 index 00000000..a5333055 --- /dev/null +++ b/backupninja/pull @@ -0,0 +1,93 @@ +# +# backupninja handler to do incremental pull backups using +# rsync and hardlinks; this script grabs folders from a remote +# server and stores incrementally in a local folder. its based on +# +# http://www.mikerubel.org/computers/rsync_snapshots/ +# +# feedback: rhatto at riseup.net | gpl +# + +setsection general +getconf log /var/log/backupninja-pull.log +getconf backupdir +getconf rotate +getconf days + +setsection source +getconf user +getconf server +getconf include +getconf exclude +getconf ssh +getconf rsync + +function rotate { + + # please use an absolute path + + if [[ "$2" < 4 ]]; then + error "Rotate: minimum of 4 rotations" + exit 1 + fi + + if [ -d $1.$2 ]; then + mv $1.$2 $1.tmp + fi + + for ((n=`echo "$2 - 1" | bc`; n >= 0; n--)); do + if [ -d $1.$n ]; then + dest=`echo "$n + 1" | bc` + mv $1.$n $1.$dest + touch $1.$dest + fi + done + + if [ -d $1.tmp ]; then + mv $1.tmp $1.0 + fi + + if [ -d $1.1 ]; then + cp -alf $1.1/. $1.0 + fi + +} + +backupdir="/$backupdir" + +if [ ! -d "$backupdir" ]; then + error "Backupdir $backupdir does not exist" + exit 1 +fi + +if [ -z "$days" ]; then + keep="4" +else + keep="`echo $days - 1 | bc -l`" +fi + +for path in $exclude; do + EXCLUDES="$EXCLUDES --exclude=$path" +done + +echo "Starting backup at `date`" >> $log + +for SECTION in $include; do + + section="`basename $SECTION`" + + if [ ! -d "$backupdir/$SECTION/$section.0" ]; then + mkdir -p $backupdir/$SECTION/$section.0 + fi + + info "Rotating $backupdir/$SECTION/$SECTION..." + echo "Rotating $backupdir/$SECTION/$SECTION..." >> $log + rotate $backupdir/$SECTION/$section $keep + info "Syncing $SECTION on $backupdir/$SECTION/$section.0..." + + $rsync "$ssh $user@$server:/$SECTION/ $backupdir/$SECTION/$section.0 >> $log + touch $backupdir/$SECTION/$section.0 + +done + +echo "Finnishing backup at `date`" >> $log diff --git a/backupninja/rub b/backupninja/rub index 4adfe811..cee94821 100755 --- a/backupninja/rub +++ b/backupninja/rub @@ -29,7 +29,7 @@ # setsection general -getconf log +getconf log /var/log/backupninja-rub.log getconf partition getconf fsck getconf read_only @@ -120,18 +120,18 @@ fi for SECTION in $include; do - section="`basename $SECTION`" + section="`basename $SECTION`" - if [ ! -d "$backupdir/$SECTION/$section.0" ]; then - mkdir -p $backupdir/$SECTION/$section.0 - fi + if [ ! -d "$backupdir/$SECTION/$section.0" ]; then + mkdir -p $backupdir/$SECTION/$section.0 + fi - info "Rotating $backupdir/$SECTION/$SECTION..." - echo "Rotating $backupdir/$SECTION/$SECTION..." >> $log - rotate $backupdir/$SECTION/$section $keep - info "Syncing $SECTION on $backupdir/$SECTION/$section.0..." - rsync -av --delete $EXCLUDES /$SECTION/ $backupdir/$SECTION/$section.0/ >> $log - touch $backupdir/$SECTION/$section.0 + info "Rotating $backupdir/$SECTION/$SECTION..." + echo "Rotating $backupdir/$SECTION/$SECTION..." >> $log + rotate $backupdir/$SECTION/$section $keep + info "Syncing $SECTION on $backupdir/$SECTION/$section.0..." + rsync -av --delete $EXCLUDES /$SECTION/ $backupdir/$SECTION/$section.0/ >> $log + touch $backupdir/$SECTION/$section.0 done |