4 # initializing some variables
5 backup_date=`date | awk '{ print $3"."$2"."$6 }'`
9 # set the backup directory
10 if [ "$host" = "gate" ] ; then
11 #mount -tnfs hackstation:/mnt/lfs/backup /mnt/nfs
13 elif [ "$host" = "sparc" ] ; then
14 #mount -tnfs hackstation:/mnt/lfs/backup /mnt/nfs
16 elif [ "$host" = "mobile" ] ; then
17 #mount -tnfs hackstation:/mnt/lfs/backup /mnt/nfs
19 elif [ "$host" = "right-hand" ] ; then
20 #mount -tnfs hackstation:/mnt/lfs/backup /mnt/nfs
22 elif [ "$host" = "hackstation" ] ; then
23 backup_dir="/mnt/lfs/backup"
24 elif [ "$host" = "hdw" ] ; then
27 echo "pls adept the script for $host ..."
31 if [ "$2" = "-backup_dir" -a -d $3 ] ; then
32 echo "using $3 as a backup directory ..."
36 # set kernel version(s) to store their .config
37 if [ -d /usr/src/linux ] ; then
38 kernel_num=`ls /usr/src/ | grep 'linux-' | awk -F- '{ print $2 }'`
42 # which method to use?
43 if [ "$1" = "tar" ] ; then
45 elif [ "$1" = "dir" ] ; then
47 elif [ -z "$1" ] ; then
51 echo "usage: $0 [tar|dir] (-backup_dir /foo/bar)"
53 echo "tar: creates an archive called backup_${backup_date}.tar.bz2"
54 echo "dir: creates just the directory backup_${backup_date}"
60 if [ -d ${backup_dir}/${host}-backup-${backup_date} ] ; then
61 echo "u already did a backup today! remove it manually first!"
65 mkdir $backup_dir/${host}-backup-${backup_date} && cd ${backup_dir}/${host}-backup-${backup_date}
70 mkdir ./${host}-conf && cd ./${host}-conf
72 for i in $kernel_num; do
73 if [ -f /usr/src/linux-${i}*/.config ] ; then
74 echo "copying /usr/src/linux/.config"
75 cp /usr/src/linux-${i}*/.config ./$host-kernel-${i}-config
80 for i in conf opt ppp; do
81 if [ -d /etc/$i ] ; then
82 echo "copying /etc/$i"
88 for i in `ls -A /etc/conf`; do
89 if [ -f /etc/init.d/$i ] ; then
90 echo "copying /etc/init.d/$i"
91 cp /etc/init.d/$i ./etc/init.d
95 for i in dhcpd.conf fstab hosts host.conf hosts.allow hosts.deny lilo.conf \
96 profile sendmail.cf resolv.conf exports; do
97 if [ -f /etc/$i ] ; then
98 echo "copying /etc/$i"
103 if [ -f /etc/X11/XF86Config ] ; then
105 echo "copying /etc/X11/XF86Config*"
106 cp /etc/X11/XF86Config* ./etc/X11
110 # specific config stuff
112 # gate specific config stuff!
113 if [ "$host" = "gate" ] ; then
116 if [ -d /etc/mail ] ; then
117 echo "copying /etc/mail directory"
118 cp -r /etc/mail ./etc
122 mkdir -p ./irc/networks
123 [ -f /opt/unreal/etc/unrealircd.conf ] && \
124 cp /opt/unreal/etc/unrealircd.conf ./irc/unrealircd_new.conf
125 for i in ircd.conf networks/hackdaworld.network \
126 networks/unrealircd.conf; do
127 [ -f /home/irc/Unreal3.1.1/$i ] && \
128 cp /home/irc/Unreal3.1.1/$i ./irc/$i
130 [ -f /home/irc/services_new/services.conf ] && \
131 cp /home/irc/services_new/services.conf ./irc
132 for i in rebecka defcon_one elin; do
133 [ -f /home/irc/eggdrop/$i ] && cp /home/irc/eggdrop/$i* ./irc
141 # data backup (specific)
142 cd ${backup_dir}/${host}-backup-${backup_date}
145 if [ "$host" = "gate" ] ; then
147 # minimalist and mail stuff
148 mkdir -p minimalist_spool mail_admin mail_hackbard
149 echo "copying minimalist and mail stuff"
150 cp -r /opt/minimalist/spool/* ./minimalist_spool
151 cp -r /home/hackbard/* ./mail_hackbard
152 cp -r /home/admin/* ./mail_admin
157 echo "copying /chroot/$i"
158 tar -cf ./chroot/$i.tar /chroot/$i
163 # hackstation specific data
164 if [ "$host" = "hackstation" -o "$host" = "mobile" -o "$host" = "hdw" ] ; then
167 mkdir -p ./home/hackbard
169 for i in projects software store; do
170 [ -d /home/hackbard/$i ] && \
171 cp -r /home/hackbard/$i ./home/hackbard
173 for i in xinitrc_evil xinitrc_wm .xinitrc GNUstep .Xauthority \
174 .Xdefaults .signature; do
175 [ -f /home/hackbard/$i ] && \
176 cp -r /home/hackbard/$i ./home/hackbard
182 # data stuff (none specific)
184 # extensions, stored on root
185 if [ -d /root/${host}_exts ] ; then
186 echo "copying ${host}_exts"
187 cp -r /root/${host}_exts ./
191 if [ -d /root/${host}_bunker ] ; then
192 echo "copying ${host}_bunker"
193 cp -r /root/${host}_bunker ./
197 cp -r $HOME/scripts ./
200 # finished copying stuff, entering last backup procedure now :)))
204 if [ "$method" = "tar" ] ; then
206 tar cf ./${host}-backup-${backup_date}.tar \
207 ./${host}-backup-${backup_date}
208 rm -r ./${host}-backup-${backup_date}
209 bzip2 ./${host}-backup-${backup_date}.tar
213 # end! umounting nfs shared backup directory
214 if [ "$host" != "hackstation" ] ; then
215 echo "umounting nfs backup - dir"
216 #cd $HOME && umount /mnt/nfs