X-Git-Url: https://hackdaworld.org/gitweb/?p=scripts%2Fscripts.git;a=blobdiff_plain;f=backup.sh;fp=backup.sh;h=08019f01c55c2e005fe6fc728e9c2c12d718dc78;hp=57cb9e39e5a1faeff74e6f36244a9d35163413b2;hb=639e6b035157d1c8de8e50eaae4526b51eb97426;hpb=79539c1170b037c32b8f9fd69a3b58000edd5366 diff --git a/backup.sh b/backup.sh index 57cb9e3..08019f0 100755 --- a/backup.sh +++ b/backup.sh @@ -1,51 +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` -[ ! -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" @@ -62,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 @@ -95,7 +93,7 @@ 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 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 @@ -176,7 +174,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 @@ -246,9 +244,9 @@ fi # 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 ..."