Hi,

I got a small script that I use to backup my mailserver every saturday. My
problem is that a few times a year the machine i use for backup is taken
offsite (we haul or office around a lot). Then the script stalls because
the nfs mount fails. Naturally this becomes a problem. Could someone supply
me som sh or bash scripting code so I can make sure that this will not
happen, and that the script stops and just starts cyrus (maybe with a mail
to someone as well).

Tarjei
#!/bin/sh
# sauve-imap.sh
# stop servers
/etc/rc.d/init.d/cyrus stop
/etc/rc.d/init.d/ldap stop

/usr/sbin/slapcat > /tmp/ldap.ldif
# start ldap.
/etc/rc.d/init.d/ldap start

#tar IMAP
/bin/tar cvzf /backup/var-imap.tgz /var/imap/
/bin/tar cvzf /backup/spool-imap.tgz /var/spool/imap/
# tar conf and ldap files directly to mounted nis dir. (they're not BIG)
/bin/tar
cvzf /mnt/test/conf.tgz /etc/cyrus.conf /etc/imapd.conf /etc/sasldb /etc/ope
nldap /etc/postfix
/bin/tar cvzf /mnt/test/ldap.tgz /tmp/ldap.ldif

# start cyrus
/etc/rc.d/init.d/cyrus start
# Open nfs conection:
/etc/rc.d/init.d/portmap start
#/etc/rc.d/init.d/nfs.init start
/etc/rc.d/init.d/nfslock start

# Mount dir
mount -t nfs backup.domain.com:/mailbackup /mnt/test

# move tarr'ed files to mounted nis dir.
/bin/mv /backup/var-imap.tgz /mnt/test/var-imap.tgz
/bin/mv /backup/spool-imap.tgz /mnt/test/spool-imap.tgz

# Umount
umount /mnt/test
# Stop servers:
/etc/rc.d/init.d/portmap stop
#/etc/rc.d/init.d/nfs.init stop
/etc/rc.d/init.d/nfslock stop

date >> /backup/bkup.log
echo ' backup of cyrus and ldap dirs done\n' >> /backup/bkuplog

## END




Reply via email to