5 remote_dir=/mnt/big/backup
7 local_backupdir=/mnt/bunker/backup
9 # initializing some variables
10 backup_date=`date | awk '{ print $3"."$2"."$6 }'`
15 if [ -d $remote_dir ] ; then
16 backup_dir=/mnt/big/backup
19 if [ -d $local_backupdir ] ; then
20 backup_dir=$local_backupdir
24 mount -tnfs ${remote_host}:${remote_dir} $local_mount
26 backup_dir=$local_mount
31 if [ "$res" != "0" ] ; then
32 echo "something failed detrmining the backup dir $backup_dir ..."
36 # which method to use?
37 if [ "$1" = "tar" ] ; then
39 elif [ "$1" = "dir" ] ; then
41 elif [ -z "$1" ] ; then
45 echo "usage: $0 [tar|dir] (-backup_dir /foo/bar)"
47 echo "tar: creates an archive called backup_${backup_date}.tar.bz2"
48 echo "dir: creates just the directory backup_${backup_date}"
52 if [ ! -z "$2" ] ; then
53 if [ "$2" = "-backup_dir" -a -d $3 ] ; then
54 echo "using $3 as a backup directory ..."
59 # set kernel version(s) to store their .config
60 if [ -d /usr/src/linux ] ; then
61 kernel_num=`ls /usr/src/ | grep '^linux-' | sed 's/linux-//g'`
65 if [ -d ${backup_dir}/${host}-backup-${backup_date} ] ; then
66 echo "u already did a backup today! remove it manually first!"
67 [ ! "$host" = "hackstation" ] && umount /mnt/nfs
71 mkdir $backup_dir/${host}-backup-${backup_date} && cd ${backup_dir}/${host}-backup-${backup_date}
76 mkdir ./${host}-conf && cd ./${host}-conf
78 for i in $kernel_num; do
79 if [ -f /usr/src/linux-${i}/.config ] ; then
80 echo "copying /usr/src/linux/.config"
81 cp /usr/src/linux-${i}/.config ./$host-kernel-${i}-config
86 for i in init.d conf opt ppp cups udev cron.d; do
87 if [ -d /etc/$i ] ; then
88 echo "copying /etc/$i"
93 for i in dhcpd.conf fstab hosts host.conf hosts.allow hosts.deny lilo.conf \
94 profile sendmail.cf resolv.conf exports fb.modes inetd.conf \
95 xinetd.conf mp3user mp3db.conf modules.conf named.conf \
96 modprobe.devfs modprobe.conf devfsd.conf crontab ethers; 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
108 if [ -f /etc/X11/xorg.conf ] ; then
110 echo "copying /etc/X11/xorg.conf*"
111 cp /etc/X11/xorg.conf* ./etc/X11
115 if [ -d /var/spool/cron/crontabs ] ; then
116 echo "copying crontab files"
117 cp -r /var/spool/cron/crontabs .
121 # specific config stuff
123 # gate specific config stuff!
124 if [ "$host" = "gate" ] ; then
127 if [ -d /etc/mail ] ; then
128 echo "copying /etc/mail directory"
129 cp -r /etc/mail ./etc
133 if [ -d /home/mlist ] ; then
134 echo "copying mlist procmail config"
135 cp -r /home/mlist mlsit_pm_config
140 [ -f /etc/opt/unrealircd/unrealircd.conf ] && \
141 cp /etc/opt/unrealircd/unrealircd.conf ./ircd
144 mkdir -p ./minimalist
145 [ -f /etc/opt/minimalist/minimalist.conf ] && \
146 cp /etc/opt/minimalist/minimalist.conf ./minimalist
149 # right-hand specific config stuff
150 if [ "$host" = "right-hand" ] ; then
151 if [ -d /var/named ] ; then
153 echo "copying dns data"
154 cp -r /var/named/* ./named
156 if [ -f /etc/opt/apache*/httpd.conf ] ; then
158 cp /etc/opt/apache*/httpd.conf ./apache
166 # data backup (specific)
167 cd ${backup_dir}/${host}-backup-${backup_date}
170 if [ "$host" = "gate" ] ; then
173 for i in `ls -A /var/mail`; do
175 echo "copying mail stuff"
176 cp /var/mail/$i ./mail_$i
181 if [ "$host" = "right-hand" ] ; then
184 if [ -d /chroot/$i ] ; then
185 echo "copying /chroot/$i"
186 tar -cf ./chroot/$i.tar /chroot/$i
191 # hackstation / mobile / hdw / sparc specific data
192 if [ "$host" = "hackstation" -o "$host" = "mobile" -o "$host" = "hdw" -o "$host" = "sparc" -o "$host" = "compaq" ] ; then
195 mkdir -p ./home/hackbard
196 echo -n "copying home ..."
197 for i in temp test; do
199 [ -d /home/hackbard/$i ] && \
200 cp -r /home/hackbard/$i ./home/hackbard
202 for i in xinitrc_evil xinitrc_wm .xinitrc GNUstep .Xauthority \
203 .Xdefaults .XHkeys .signature .directfbrc .bashrc \
204 sp12 .licq .irssi; do
206 [ -e /home/hackbard/$i ] && \
207 cp -r /home/hackbard/$i ./home/hackbard
209 [ -d /home/hackbard/.mozilla ] &&
210 cp /home/hackbard/.mozilla/*/*/bookmarks.html \
211 mozilla-bookmarks.html
212 [ -d /home/hackbard/.ssh ] && cp -r /home/hackbard/.ssh ./home/hackbard
216 if [ -d /tftpboot ] ; then
218 echo "copying tftpboot stuff"
219 cp -r /tftpboot/* ./tftpboot
223 for i in hunz_prism hunz_lucent roman_orinoco.sh; do
224 if [ -f /root/${i}.sh ]; then
226 cp /root/${i}.sh ./root
233 # data stuff (none specific)
236 cp -r $HOME/scripts ./
239 # finished copying stuff, entering last backup procedure now :)))
243 if [ "$method" = "tar" ] ; then
245 tar cf ./${host}-backup-${backup_date}.tar \
246 ./${host}-backup-${backup_date}
247 rm -r ./${host}-backup-${backup_date}
248 bzip2 ./${host}-backup-${backup_date}.tar
252 # end! umounting nfs shared backup directory
253 if [ "$mounted" = "1" ] ; then
254 echo "umounting nfs backup - dir"
255 cd $HOME && umount $local_mount