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 ..."
32 if [ ! -z "$2" ] ; then
33 if [ "$2" = "-backup_dir" -a -d $3 ] ; then
34 echo "using $3 as a backup directory ..."
40 # set kernel version(s) to store their .config
41 if [ -d /usr/src/linux ] ; then
42 kernel_num=`ls /usr/src/ | grep 'linux-' | awk -F- '{ print $2 }'`
46 # which method to use?
47 if [ "$1" = "tar" ] ; then
49 elif [ "$1" = "dir" ] ; then
51 elif [ -z "$1" ] ; then
55 echo "usage: $0 [tar|dir] (-backup_dir /foo/bar)"
57 echo "tar: creates an archive called backup_${backup_date}.tar.bz2"
58 echo "dir: creates just the directory backup_${backup_date}"
64 if [ -d ${backup_dir}/${host}-backup-${backup_date} ] ; then
65 echo "u already did a backup today! remove it manually first!"
69 mkdir $backup_dir/${host}-backup-${backup_date} && cd ${backup_dir}/${host}-backup-${backup_date}
74 mkdir ./${host}-conf && cd ./${host}-conf
76 for i in $kernel_num; do
77 if [ -f /usr/src/linux-${i}*/.config ] ; then
78 echo "copying /usr/src/linux/.config"
79 cp /usr/src/linux-${i}*/.config ./$host-kernel-${i}-config
84 for i in conf opt ppp; do
85 if [ -d /etc/$i ] ; then
86 echo "copying /etc/$i"
92 for i in `ls -A /etc/conf`; do
93 if [ -f /etc/init.d/$i ] ; then
94 echo "copying /etc/init.d/$i"
95 cp /etc/init.d/$i ./etc/init.d
99 for i in dhcpd.conf fstab hosts host.conf hosts.allow hosts.deny lilo.conf \
100 profile sendmail.cf resolv.conf exports; do
101 if [ -f /etc/$i ] ; then
102 echo "copying /etc/$i"
107 if [ -f /etc/X11/XF86Config ] ; then
109 echo "copying /etc/X11/XF86Config*"
110 cp /etc/X11/XF86Config* ./etc/X11
114 # specific config stuff
116 # gate specific config stuff!
117 if [ "$host" = "gate" ] ; then
120 if [ -d /etc/mail ] ; then
121 echo "copying /etc/mail directory"
122 cp -r /etc/mail ./etc
126 mkdir -p ./irc/networks
127 [ -f /opt/unreal/etc/unrealircd.conf ] && \
128 cp /opt/unreal/etc/unrealircd.conf ./irc/unrealircd_new.conf
129 for i in ircd.conf networks/hackdaworld.network \
130 networks/unrealircd.conf; do
131 [ -f /home/irc/Unreal3.1.1/$i ] && \
132 cp /home/irc/Unreal3.1.1/$i ./irc/$i
134 [ -f /home/irc/services_new/services.conf ] && \
135 cp /home/irc/services_new/services.conf ./irc
136 for i in rebecka defcon_one elin; do
137 [ -f /home/irc/eggdrop/$i ] && cp /home/irc/eggdrop/$i* ./irc
145 # data backup (specific)
146 cd ${backup_dir}/${host}-backup-${backup_date}
149 if [ "$host" = "gate" ] ; then
151 # minimalist and mail stuff
152 mkdir -p minimalist_spool mail_admin mail_hackbard
153 echo "copying minimalist and mail stuff"
154 cp -r /opt/minimalist/spool/* ./minimalist_spool
155 cp -r /home/hackbard/* ./mail_hackbard
156 cp -r /home/admin/* ./mail_admin
161 echo "copying /chroot/$i"
162 tar -cf ./chroot/$i.tar /chroot/$i
167 # hackstation specific data
168 if [ "$host" = "hackstation" -o "$host" = "mobile" -o "$host" = "hdw" -o "$host" = "sparc" ] ; then
171 mkdir -p ./home/hackbard
173 for i in projects software store; do
174 [ -d /home/hackbard/$i ] && \
175 cp -r /home/hackbard/$i ./home/hackbard
177 for i in xinitrc_evil xinitrc_wm .xinitrc GNUstep .Xauthority \
178 .Xdefaults .signature; do
179 [ -f /home/hackbard/$i ] && \
180 cp -r /home/hackbard/$i ./home/hackbard
182 cp -r /home/hackbard/.ssh ./home/hackbard
187 # data stuff (none specific)
189 # extensions, stored on root
190 if [ -d /root/${host}_exts ] ; then
191 echo "copying ${host}_exts"
192 cp -r /root/${host}_exts ./
196 if [ -d /root/${host}_bunker ] ; then
197 echo "copying ${host}_bunker"
198 cp -r /root/${host}_bunker ./
202 cp -r $HOME/scripts ./
205 # finished copying stuff, entering last backup procedure now :)))
209 if [ "$method" = "tar" ] ; then
211 tar cf ./${host}-backup-${backup_date}.tar \
212 ./${host}-backup-${backup_date}
213 rm -r ./${host}-backup-${backup_date}
214 bzip2 ./${host}-backup-${backup_date}.tar
218 # end! umounting nfs shared backup directory
219 if [ "$host" != "hackstation" ] ; then
220 echo "umounting nfs backup - dir"
221 #cd $HOME && umount /mnt/nfs