From 07c133fec78ce26e0bbfdeb20f9a7cc8a7667b4a Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 25 Nov 2002 17:33:53 +0000 Subject: [PATCH] startet scripts repository -------------------------- --- README | 6 ++ backup.sh | 215 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 221 insertions(+) create mode 100644 README create mode 100755 backup.sh diff --git a/README b/README new file mode 100644 index 0000000..b196c3a --- /dev/null +++ b/README @@ -0,0 +1,6 @@ +# some scripts + +- backup.sh + simple script making backups of important files and data. + +EOF diff --git a/backup.sh b/backup.sh new file mode 100755 index 0000000..fe6426f --- /dev/null +++ b/backup.sh @@ -0,0 +1,215 @@ +#!/bin/bash + + +# 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 + backup_dir="/mnt/nfs" +else + echo "pls adept the script for $host ..." + exit 1 +fi + + +# set kernel version(s) to store their .config +if [ -d /usr/src/linux ] ; then + kernel_num=`ls /usr/src/ | grep 'linux-' | awk -F- '{ print $2 }'` +fi + + +# which method to use? +if [ "$1" = "tar" ] ; then + method="tar" +elif [ "$1" = "dir" ] ; then + method="dir" +elif [ -z "$1" ] ; then + method="tar" +else + echo "aborting!" + echo "usage: $0 [tar|dir]" + echo + echo "tar\t: creates an archive called backup_${backup_date}.tar.bz2" + echo "dir\t: creates just the directory backup_${backup_date}" + exit 1 +fi + + +# creating backup +if [ -d ${backup_dir}/${host}-backup-${backup_date} ] ; then + echo "u already did a backup today! remove it manually first!" + exit 1 +fi + +mkdir $backup_dir/${host}-backup-${backup_date} && cd ${backup_dir}/${host}-backup-${backup_date} + + +#config stuff +echo "config stuff:" +mkdir ./${host}-conf && cd ./${host}-conf + +for i in $kernel_num; do + if [ -f /usr/src/linux-${i}*/.config ] ; then + echo "copying /usr/src/linux/.config" + cp /usr/src/linux-${i}*/.config ./$host-kernel-${i}-config + fi +done + +mkdir ./etc +for i in conf opt ppp; do + if [ -d /etc/$i ] ; then + echo "copying /etc/$i" + cp -r /etc/$i ./etc + fi +done + +mkdir ./etc/init.d +for i in `ls -A /etc/conf`; do + if [ -f /etc/init.d/$i ] ; then + echo "copying /etc/init.d/$i" + cp /etc/init.d/$i ./etc/init.d + fi +done + +for i in dhcpd.conf fstab hosts host.conf hosts.allow hosts.deny lilo.conf \ + profile sendmail.cf resolv.conf exports; do + if [ -f /etc/$i ] ; then + echo "copying /etc/$i" + cp /etc/$i ./etc + fi +done + +if [ -f /etc/X11/XF86Config ] ; then + mkdir -p ./etc/X11 + echo "copying /etc/X11/XF86Config*" + cp /etc/X11/XF86Config* ./etc/X11 +fi + + +# specific config stuff + +# gate specific config stuff! +if [ "$host" = "gate" ] ; then + + # mail config stuff + if [ -d /etc/mail ] ; then + echo "copying /etc/mail directory" + cp -r /etc/mail ./etc + fi + + # irc stuff + mkdir -p ./irc/networks + [ -f /opt/unreal/etc/unrealircd.conf ] && \ + cp /opt/unreal/etc/unrealircd.conf ./irc/unrealircd_new.conf + for i in ircd.conf networks/hackdaworld.network \ + networks/unrealircd.conf; do + [ -f /home/irc/Unreal3.1.1/$i ] && \ + cp /home/irc/Unreal3.1.1/$i ./irc/$i + done + [ -f /home/irc/services_new/services.conf ] && \ + cp /home/irc/services_new/services.conf ./irc + for i in rebecka defcon_one elin; do + [ -f /home/irc/eggdrop/$i ] && cp /home/irc/eggdrop/$i* ./irc + done + +fi + +# data stuff +echo "data stuff:" + +# data backup (specific) +cd ${backup_dir}/${host}-backup-${backup_date} + +# gate specific data +if [ "$host" = "gate" ] ; then + + # minimalist and mail stuff + mkdir -p minimalist_spool mail_admin mail_hackbard + echo "copying minimalist and mail stuff" + cp -r /opt/minimalist/spool/* ./minimalist_spool + cp -r /home/hackbard/* ./mail_hackbard + cp -r /home/admin/* ./mail_admin + + # www and cvs stuff + mkdir chroot + for i in www cvs; do + echo "copying /chroot/$i" + tar -cf ./chroot/$i.tar /chroot/$i + done + +fi + +# hackstation specific data +if [ "$host" = "hackstation" -o "$host" = "mobile" -o "$host" = "hdw" ] ; then + + # home of hackbard + mkdir -p ./home/hackbard + echo "copying home" + for i in projects software store; do + [ -d /home/hackbard/$i ] && \ + cp -r /home/hackbard/$i ./home/hackbard + done + for i in xinitrc_evil xinitrc_wm .xinitrc GNUstep .Xauthority \ + .Xdefaults .signature; do + [ -f /home/hackbard/$i ] && \ + cp -r /home/hackbard/$i ./home/hackbard + done + +fi + + +# data stuff (none specific) + +# extensions, stored on root +if [ -d /root/${host}_exts ] ; then + echo "copying ${host}_exts" + cp -r /root/${host}_exts ./ +fi + +# dying software +if [ -d /root/${host}_bunker ] ; then + echo "copying ${host}_bunker" + cp -r /root/${host}_bunker ./ +fi + +# backing up myself +cp -r $HOME/scripts ./ + + +# finished copying stuff, entering last backup procedure now :))) + +cd $backup_dir + +if [ "$method" = "tar" ] ; then + echo "creating tar" + tar cf ./${host}-backup-${backup_date}.tar \ + ./${host}-backup-${backup_date} + rm -r ./${host}-backup-${backup_date} + bzip2 ./${host}-backup-${backup_date}.tar +fi + + +# end! umounting nfs shared backup directory +if [ "$host" != "hackstation" ] ; then + echo "umounting nfs backup - dir" + #cd $HOME && umount /mnt/nfs +fi + +echo "done ..." -- 2.20.1