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 # specific config stuff
117 # gate specific config stuff!
118 if [ "$host" = "gate" ] ; then
121 if [ -d /etc/mail ] ; then
122 echo "copying /etc/mail directory"
123 cp -r /etc/mail ./etc
127 if [ -d /home/mlist ] ; then
128 echo "copying mlist procmail config"
129 cp -r /home/mlist mlsit_pm_config
134 [ -f /etc/opt/unrealircd/unrealircd.conf ] && \
135 cp /etc/opt/unrealircd/unrealircd.conf ./ircd
138 mkdir -p ./minimalist
139 [ -f /etc/opt/minimalist/minimalist.conf ] && \
140 cp /etc/opt/minimalist/minimalist.conf ./minimalist
143 # right-hand specific config stuff
144 if [ "$host" = "right-hand" ] ; then
145 if [ -d /var/named ] ; then
147 echo "copying dns data"
148 cp -r /var/named/* ./named
150 if [ -f /etc/opt/apache*/httpd.conf ] ; then
152 cp /etc/opt/apache*/httpd.conf ./apache
160 # data backup (specific)
161 cd ${backup_dir}/${host}-backup-${backup_date}
164 if [ "$host" = "gate" ] ; then
167 for i in `ls -A /var/mail`; do
169 echo "copying mail stuff"
170 cp /var/mail/$i ./mail_$i
175 if [ "$host" = "right-hand" ] ; then
178 if [ -d /chroot/$i ] ; then
179 echo "copying /chroot/$i"
180 tar -cf ./chroot/$i.tar /chroot/$i
185 # hackstation / mobile / hdw / sparc specific data
186 if [ "$host" = "hackstation" -o "$host" = "mobile" -o "$host" = "hdw" -o "$host" = "sparc" -o "$host" = "compaq" ] ; then
189 mkdir -p ./home/hackbard
190 echo -n "copying home ..."
191 for i in temp test; do
193 [ -d /home/hackbard/$i ] && \
194 cp -r /home/hackbard/$i ./home/hackbard
196 for i in xinitrc_evil xinitrc_wm .xinitrc GNUstep .Xauthority \
197 .Xdefaults .XHkeys .signature .directfbrc .bashrc \
198 sp12 .licq .irssi; do
200 [ -e /home/hackbard/$i ] && \
201 cp -r /home/hackbard/$i ./home/hackbard
203 [ -d /home/hackbard/.mozilla ] &&
204 cp /home/hackbard/.mozilla/*/*/bookmarks.html \
205 mozilla-bookmarks.html
206 [ -d /home/hackbard/.ssh ] && cp -r /home/hackbard/.ssh ./home/hackbard
210 if [ -d /tftpboot ] ; then
212 echo "copying tftpboot stuff"
213 cp -r /tftpboot/* ./tftpboot
217 for i in hunz_prism hunz_lucent roman_orinoco.sh; do
218 if [ -f /root/${i}.sh ]; then
220 cp /root/${i}.sh ./root
227 # data stuff (none specific)
230 cp -r $HOME/scripts ./
233 # finished copying stuff, entering last backup procedure now :)))
237 if [ "$method" = "tar" ] ; then
239 tar cf ./${host}-backup-${backup_date}.tar \
240 ./${host}-backup-${backup_date}
241 rm -r ./${host}-backup-${backup_date}
242 bzip2 ./${host}-backup-${backup_date}.tar
246 # end! umounting nfs shared backup directory
247 if [ "$mounted" = "1" ] ; then
248 echo "umounting nfs backup - dir"
249 cd $HOME && umount $local_mount