#!/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`
-[ ! -d /mnt/nfs ] && mkdir -p /mnt/nfs
-
-# 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"
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
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 modules.conf named.conf \
- modprobe.devfs modprobe.conf devfsd.conf crontab; do
+ modprobe.devfs modprobe.conf devfsd.conf crontab ethers; do
if [ -f /etc/$i ] ; then
echo "copying /etc/$i"
cp /etc/$i ./etc
# 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
# end! umounting nfs shared backup directory
-if [ "$host" != "hackstation" ] ; then
+if [ "$mounted" = "0" ] ; then
echo "umounting nfs backup - dir"
- cd $HOME && umount /mnt/nfs
+ cd $HOME && umount $local_mount
fi
echo "done ..."