From 2dea80361b76b0bdc0e71aee2b14c95a6c7a2b51 Mon Sep 17 00:00:00 2001
From: Per Cederqvist <ceder@lysator.liu.se>
Date: Sat, 14 Oct 2006 17:27:18 +0000
Subject: [PATCH] Initial checkin of lysrdiff.

Initial checkin of the proof-of-concept scripts used to backup
some of the most important data on Lysator to sedesopim.

* fetch-backup-work: New script.  Define all backup tasks by quering
  auto_home on nema, and listing certain directories on stalingrad and
  uhumhummy.  As set up, this will find home directories, user www
  directories that use Apache (not Roxen), and CVS and SVN projects on
  the stalingrad server.  Note, however, that only a select few of the
  tasks are actually selected, due to the current disc shortage on
  sedesopim.

* backup-one-task: New script.  Run rdiff-backup to back up one task.

* backup-all: New script.  This script repeatedly calls
  backup-one-task for all defined tasks.
---
 ChangeLog         | 18 ++++++++++++++++++
 backup-all        | 11 +++++++++++
 backup-one-task   | 36 ++++++++++++++++++++++++++++++++++++
 fetch-backup-work | 35 +++++++++++++++++++++++++++++++++++
 4 files changed, 100 insertions(+)
 create mode 100644 ChangeLog
 create mode 100755 backup-all
 create mode 100755 backup-one-task
 create mode 100755 fetch-backup-work

diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..7ead373
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,18 @@
+2006-10-14  Per Cederqvist  <ceder@lysator.liu.se>
+
+	Initial checkin of the proof-of-concept scripts used to backup
+	some of the most important data on Lysator to sedesopim.
+
+	* fetch-backup-work: New script.  Define all backup tasks by
+	quering auto_home on nema, and listing certain directories on
+	stalingrad and uhumhummy.  As set up, this will find home
+	directories, user www directories that use Apache (not Roxen), and
+	CVS and SVN projects on the stalingrad server.  Note, however,
+	that only a select few of the tasks are actually selected, due to
+	the current disc shortage on sedesopim.
+
+	* backup-one-task: New script.  Run rdiff-backup to back up one
+	task.
+
+	* backup-all: New script.  This script repeatedly calls
+	backup-one-task for all defined tasks.
diff --git a/backup-all b/backup-all
new file mode 100755
index 0000000..94473d0
--- /dev/null
+++ b/backup-all
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+df -h /nobackup/backup.lysator/backups
+
+while read category subcategory server serverpath
+do
+  /nobackup/backup.lysator/bin/backup-one-task \
+	 "$category" "$subcategory" "$server" "$serverpath"
+done < /nobackup/backup.lysator/var/tasks
+
+df -h /nobackup/backup.lysator/backups
diff --git a/backup-one-task b/backup-one-task
new file mode 100755
index 0000000..f0c918e
--- /dev/null
+++ b/backup-one-task
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+if [ $# != 4 ]
+then
+    echo $0: usage: $0 category subcategory server serverpath >&2
+    echo Example: $0 home ceder inservitus /export/home/ceder >&2
+    exit 1
+fi
+
+category="$1"
+subcategory="$2"
+server="$3"
+serverpath="$4"
+
+case "$server" in
+    manhattan) remoterdiff=/usr/bin/rdiff-backup;;
+    stalingrad) remoterdiff=/usr/bin/rdiff-backup;;
+    *) remoterdiff=/usr/local/bin/rdiff-backup;;
+esac
+
+base="/nobackup/backup.lysator/backups/$category/$subcategory"
+exclude="$base"/exclude
+files="$base"/files
+
+mkdir -p "$files"
+rm -f "$exclude"
+
+# Fetch an up-to-date exclude file.
+scp -i /root/.ssh/backupkey "$server":"$serverpath"/.lysbackupexclude \
+     "$exclude"
+
+rdiff-backup --exclude-other-filesystems --null-separator \
+ --remote-schema \
+    'ssh -a -k -x -i /root/.ssh/backupkey %s '$remoterdiff' --server' \
+    "$server"::"$serverpath" "$files" \
+ && touch "$base"/last-good-backup
diff --git a/fetch-backup-work b/fetch-backup-work
new file mode 100755
index 0000000..9fa70b1
--- /dev/null
+++ b/fetch-backup-work
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+rm /nobackup/backup.lysator/var/tasks
+
+ssh stalingrad ls -1 /svnroot \
+ | sort \
+ | head -10 \
+ | awk '{print "lsvn", $1, "stalingrad /svnroot/" $1}' \
+>> /nobackup/backup.lysator/var/tasks
+
+ssh stalingrad ls -1 /cvsroot \
+ | sort \
+ | head -10 \
+ | awk '{print "lyscvs", $1, "stalingrad /cvsroot/" $1}' \
+>> /nobackup/backup.lysator/var/tasks
+
+ssh uhumhummy ls -1 /lysator/lyswww/users/common \
+ | grep -v USAGE \
+ | grep -v THIS_IS_USERWEB \
+ | grep -v '^cap\.fm$' \
+ | sort \
+ | grep -v '^a' \
+ | grep -v '^b' \
+ | head -50 \
+ | awk '{print "lyswww", $1, "uhumhummy /lysator/lyswww/users/common/" $1}' \
+>> /nobackup/backup.lysator/var/tasks
+
+ssh nema.lysator.liu.se ypcat -k auto_home \
+ | sort \
+ | grep -v DELETE \
+ | grep -v '^ *$' \
+ | head -75 \
+ | sed 's/:/ /' \
+ | sed 's/^/home /' \
+>> /nobackup/backup.lysator/var/tasks
-- 
GitLab