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

Vorschlag: Skript zum Sichern Debian-relevanter Daten



Gruesse!

Matthias H.'s Mail zu reiserfs Problem brachte mich auf die Idee, mein
Debian-Backup-Skript mal wieder etwas zu pflegen. Ich habe das ML-Archiv
nochmal durchforstet und außer den Einzel-Tips keine "Komplett-Lösung"
gefunden.

Deshalb ist es evtl. eine gute Idee, das mal hier zu posten. Zum einen
mag es für den einen oder anderen schon ganz hilfreich sein. Zum anderen
wäre natürlich gut, wenn noch Vorschläge kämen welche anderen Daten noch
für ein Debian wichtig wären.

Ziel sollte IMHO sein, Daten parat zu haben um ein Debian mit
Bordmitteln wieder (re)-installieren zu können. 

Das Skript muß als root ausgeführt werden.
Wem der ganze Inhalt nichts sagt, sollte evtl. ein paar Kommentare
abwarten bevor ihr es einfach so ausführt.
Ich habe es nur in der bash benutzt. Gibt es evtl. Probleme mit anderen
Shells?

/home/gerhard/work/saveyourdeb
-----------------------
#!/bin/sh
#
# Backup important Files and Settings from your Debian system.
#
# HINT: If you do a really backup of your system you don't need this!
#
# Edit SYD_Dir, SYD_TGZ and hd_with_mbr to your local conditions.
##
###
# Directory for saving data
SYD_Dir="/var/local/saveyourdeb"
# Location of tar archive from above directory
SYD_TGZ="/var/local/saveyourdeb-$(hostname)-$(date +%x).tar.gz"
# Device where your master boot record is located
hd_with_mbr=/dev/hda
##
###
# With Parameter -q we will be quiet (for cron etc)
if [ ${1:-""} = "-q" ]; then
  NOQUIET="[ 1 = 0 ]"
else
  NOQUIET="[ 1 = 1 ]"
fi
##
###
$NOQUIET && echo -n "SaveYourDeb directory is" "$SYD_Dir""... "
if [ ! -d $SYD_Dir ]; then
  mkdir $SYD_Dir 2>/dev/null
  $NOQUIET && echo -n "(Creating)"
fi
$NOQUIET && echo
##
###
# Save partition table
$NOQUIET && echo " -> Saving partition table..."
fdisk -l > $SYD_Dir/fdisk.table
##
###
# Save the master boot record
$NOQUIET && echo " -> Saving MBR from $hd_with_mbr..."
dd if=$hd_with_mbr of=$SYD_Dir/mbr.img bs=512 count=1 2>/dev/null
##
###
# Save /etc as tar.gz
$NOQUIET && echo " -> Saving /etc as tar.gz archive..."
tar czf $SYD_Dir/etc.tar.gz /etc 2>/dev/null
##
###
# Save list of loaded modules
$NOQUIET && echo " -> Saving list of loaded modules..."
lsmod > $SYD_Dir/lsmod-$(uname -r).list
##
###
# Save list of installed, deleted or purged packages
# This could be reread by dpkg --set-selections
$NOQUIET && echo " -> Saving dpkg selections..."
dpkg --get-selections "*" > $SYD_Dir/dpkg-selctions.list
##
###
# Save dpkg and aptitude status files
$NOQUIET && echo " -> Saving dpkg and aptitude status files..."
cp /var/lib/aptitude/pkgstates $SYD_Dir/aptitude.pkgstates
cp /var/lib/dpkg/status $SYD_Dir/dpkg.status
##
###
# Save debconf database for reread by debconf-set-selctions
# Note: package debconf-utils must be installed!
if [ -x /usr/bin/debconf-get-selections ]; then
  $NOQUIET && echo " -> Saving debconf selections..."
  debconf-get-selections > $SYD_Dir/debconf.selections
else
  $NOQUIET && echo " -> NOT saving debconf selections. Install debconf-utils"
fi
##
###
# Save some maybe usefull infos from /proc
$NOQUIET && echo " -> Saving some informations from /proc..."
cat /proc/cpuinfo    > $SYD_Dir/proc-cpuinfo
cat /proc/interrupts > $SYD_Dir/proc-interrupts
cat /proc/ioports    > $SYD_Dir/proc-ioports
cat /proc/meminfo    > $SYD_Dir/proc-meminfo
cat /proc/modules    > $SYD_Dir/proc-modules
cat /proc/mounts     > $SYD_Dir/proc-mounts
cat /proc/partitions > $SYD_Dir/proc-partitions
cat /proc/swaps      > $SYD_Dir/proc-swaps
##
###
$NOQUIET && echo "Finished."
##
###
# Make a tar.gz from $SYD_Dir
$NOQUIET && echo "Creating tar archive $SYD_TGZ"
$NOQUIET && echo "from $SYD_Dir..."
tar czf $SYD_TGZ $SYD_Dir 2>/dev/null
-----------------------

Gruß
	Gerhard

-- 
Virus gefunden - Bundestrojaner_BT32/W
Dieser Schaedling steht auf dem Boden
der freiheitlich-demokratischen Grundordnung.
Sie haben folgende Moeglichkeiten:
Mit Nein die Abwehr abzuwenden oder mit
jeder anderen Taste die Installation fortzusetzen.



Reply to: