different backups for primary and secondary
[scripts/scripts.git] / backup.sh
index a1a0f1a..07a71c0 100755 (executable)
--- a/backup.sh
+++ b/backup.sh
@@ -1,50 +1,38 @@
 #!/bin/bash
 
+# variables
+remote_host=right-hand
+remote_dir=/mnt/big/backup
+local_mount=/mnt/nfs
+local_backupdir=/mnt/bunker/backup
 
 # initializing some variables
 backup_date=`date | awk '{ print $3"."$2"."$6 }'`
 host=`hostname`
 
-
-# set the backup directory
-if [ "$host" = "gate" ] ; then
-       mount -tnfs hackstation:/mnt/lfs/backup /mnt/nfs
-       backup_dir="/mnt/nfs"
-elif [ "$host" = "sparc" ] ; then
-       mount -tnfs hackstation:/mnt/lfs/backup /mnt/nfs
-       backup_dir="/mnt/nfs"
-elif [ "$host" = "mobile" ] ; then
-        mount -tnfs hackstation:/mnt/lfs/backup /mnt/nfs
-        backup_dir="/mnt/nfs"
-elif [ "$host" = "right-hand" ] ; then
-       mount -tnfs hackstation:/mnt/lfs/backup /mnt/nfs
-       backup_dir="/mnt/nfs"
-elif [ "$host" = "hackstation" ] ; then 
-       backup_dir="/mnt/lfs/backup"
-elif [ "$host" = "hdw" ] ; then
-       mount -tnfs hackstation:/mnt/lfs/backup /mnt/nfs
-       backup_dir="/mnt/nfs"
-elif [ "$host" = "compaq" ] ; then
-       mount -tnfs hackstation:/mnt/lfs/backup /mnt/nfs
-       backup_dir="/mnt/nfs"
+mounted=0
+res=1
+if [ -d $remote_dir ] ; then
+       backup_dir=/mnt/big/backup
+       res=0
 else
-       echo "pls adept the script for $host ..."
-       exit 1
-fi
-
-if [ ! -z "$2" ] ; then
-if [ "$2" = "-backup_dir" -a -d $3 ] ; then
-       echo "using $3 as a backup directory ..."
-       backup_dir=$3
-fi
+       if [ -d $local_backupdir ] ; then
+               backup_dir=$local_backupdir
+               res=0
+       else
+               mkdir -p $local_mount
+               mount -tnfs ${remote_host}:${remote_dir} $local_mount
+               res=$?
+               backup_dir=$local_mount
+               mounted=1
+       fi
 fi
 
-# set kernel version(s) to store their .config
-if [ -d /usr/src/linux ] ; then
-       kernel_num=`ls /usr/src/ | grep '^linux-' | sed 's/linux-//g'`
+if [ "$res" != "0" ] ; then
+       echo "something failed detrmining the backup dir $backup_dir ..."
+       exit
 fi
 
-
 # which method to use?
 if [ "$1" = "tar" ] ; then
        method="tar"
@@ -61,6 +49,17 @@ else
        exit 0
 fi
 
+if [ ! -z "$2" ] ; then
+       if [ "$2" = "-backup_dir" -a -d $3 ] ; then
+               echo "using $3 as a backup directory ..."
+               backup_dir=$3
+       fi
+fi
+
+# set kernel version(s) to store their .config
+if [ -d /usr/src/linux ] ; then
+       kernel_num=`ls /usr/src/ | grep '^linux-' | sed 's/linux-//g'`
+fi
 
 # creating backup
 if [ -d ${backup_dir}/${host}-backup-${backup_date} ] ; then
@@ -84,7 +83,7 @@ for i in $kernel_num; do
 done
 
 mkdir ./etc
-for i in init.d conf opt ppp cups; do
+for i in init.d conf opt ppp cups udev cron.d; do
        if [ -d /etc/$i ] ; then
                echo "copying /etc/$i"
                cp -r /etc/$i ./etc
@@ -93,7 +92,8 @@ done
 
 for i in dhcpd.conf fstab hosts host.conf hosts.allow hosts.deny lilo.conf \
                profile sendmail.cf resolv.conf exports fb.modes inetd.conf \
-               xinetd.conf mp3user mp3db.conf; do
+               xinetd.conf mp3user mp3db.conf modules.conf named.conf \
+               modprobe.devfs modprobe.conf devfsd.conf crontab ethers; do
        if [ -f /etc/$i ] ; then
        echo "copying /etc/$i"
        cp /etc/$i ./etc
@@ -105,6 +105,17 @@ if [ -f /etc/X11/XF86Config ] ; then
        echo "copying /etc/X11/XF86Config*"
        cp /etc/X11/XF86Config* ./etc/X11
 fi
+if [ -f /etc/X11/xorg.conf ] ; then
+       mkdir -p ./etc/X11
+       echo "copying /etc/X11/xorg.conf*"
+       cp /etc/X11/xorg.conf* ./etc/X11
+fi
+
+# crontabs
+if [ -d /var/spool/cron/crontabs ] ; then
+       echo "copying crontab files"
+       cp -r /var/spool/cron/crontabs .
+fi
 
 
 # specific config stuff
@@ -118,12 +129,37 @@ if [ "$host" = "gate" ] ; then
                cp -r /etc/mail ./etc
        fi
 
+       # mlsit procmail
+       if [ -d /home/mlist ] ; then
+               echo "copying mlist procmail config"
+               cp -r /home/mlist mlsit_pm_config
+       fi
+
        # irc stuff 
        mkdir -p ./ircd
        [ -f /etc/opt/unrealircd/unrealircd.conf ] && \
                cp /etc/opt/unrealircd/unrealircd.conf ./ircd
+       
+       # minimalist stuff 
+       mkdir -p ./minimalist
+       [ -f /etc/opt/minimalist/minimalist.conf ] && \
+               cp /etc/opt/minimalist/minimalist.conf ./minimalist
+fi
+
+# right-hand specific config stuff
+if [ "$host" = "right-hand" ] ; then
+        if [ -d /var/named ] ; then
+               mkdir ./named
+                echo "copying dns data"
+                cp -r /var/named/* ./named
+        fi
+       if [ -f /etc/opt/apache*/httpd.conf ] ; then
+               mkdir ./apache
+               cp /etc/opt/apache*/httpd.conf ./apache
+       fi
 fi
 
+
 # data stuff
 echo "data stuff:"
 
@@ -144,7 +180,7 @@ fi
 # right-hand data
 if [ "$host" = "right-hand" ] ; then
        mkdir ./chroot
-       for i in www cvs hdw; do
+       for i in www cvs; do
                if [ -d /chroot/$i ] ; then
                        echo "copying /chroot/$i"
                        tar -cf ./chroot/$i.tar /chroot/$i
@@ -153,38 +189,41 @@ if [ "$host" = "right-hand" ] ; then
 fi
 
 # hackstation / mobile / hdw / sparc specific data
-if [ "$host" = "hackstation" -o "$host" = "mobile" -o "$host" = "hdw" -o "$host" = "sparc" -o "$host" = "left-hand" ] ; then
+if [ "$host" = "hackstation" -o "$host" = "mobile" -o "$host" = "hdw" -o "$host" = "sparc" -o "$host" = "compaq" ] ; then
 
        # home of hackbard
        mkdir -p ./home/hackbard
-       echo "copying home"
-       for i in software store; do
+       echo -n "copying home ..."
+       for i in temp test; do
+               echo -n " $i,"
                [ -d /home/hackbard/$i ] && \
                        cp -r /home/hackbard/$i ./home/hackbard
        done
-       if [ "$host" = "hackstation" ]; then
-               [ -d /home/hackbard/projects ] && \
-                       cp -r /home/hackbard/projects ./home/hackbard
-       fi
        for i in xinitrc_evil xinitrc_wm .xinitrc GNUstep .Xauthority \
-                       .Xdefaults .signature .directfbrc; do
-               [ -f /home/hackbard/$i ] && \
+                       .Xdefaults .XHkeys .signature .directfbrc .bashrc \
+                       sp12 .licq .irssi; do
+               echo -n " $i,"
+               [ -e /home/hackbard/$i ] && \
                        cp -r /home/hackbard/$i ./home/hackbard
        done
+        [ -d /home/hackbard/.mozilla ] &&
+               cp /home/hackbard/.mozilla/*/*/bookmarks.html \
+                       mozilla-bookmarks.html
        [ -d /home/hackbard/.ssh ] && cp -r /home/hackbard/.ssh ./home/hackbard
+       echo " done."
        
        # tftpboot
        if [ -d /tftpboot ] ; then
                mkdir -p ./tftpboot
-               echo "copyinf tftpboot stuff"
+               echo "copying tftpboot stuff"
                cp -r /tftpboot/* ./tftpboot
        fi
 
-       # hunz config
-       for i in prism lucent; do
-               if [ -f /root/hunz_${i}.sh ]; then
+       # wlan configs
+       for i in hunz_prism hunz_lucent roman_orinoco.sh; do
+               if [ -f /root/${i}.sh ]; then
                        mkdir -p ./root
-                       cp /root/hunz_${i}.sh ./root
+                       cp /root/${i}.sh ./root
                fi
        done
 
@@ -211,9 +250,9 @@ fi
 
 
 # end! umounting nfs shared backup directory
-if [ "$host" != "hackstation" ] ; then
+if [ "$mounted" = "1" ] ; then
        echo "umounting nfs backup - dir"
-       cd $HOME && umount /mnt/nfs
+       cd $HOME && umount $local_mount
 fi
 
 echo "done ..."