#!/bin/sh ############################################################################### # Reciprocal Net project # @(#)recipnet-backup # # This simple backup program is designed to be run at either an 0.6.2 site or # an 0.9.0 site. It stops the key daemons and then generates a tarball that # contains all the site's key files. Designed to be run as root. # # 03-Jan-2008: ekoperda wrote first draft # 05-Jan-2008: ekoperda made assorted improvements ############################################################################### if [ $UID -ne 0 ]; then echo "recipnet-backup cannot be run without root privileges!" exit 1 fi # Load the configuration file. . /etc/recipnet/recipnetd.conf # Shut down those daemons that may get in our way. If they weren't already # running, it's no big deal; we'll just continue on. /sbin/service recipnetd stop /sbin/service mysqld stop # Make a copy of the configuration file to go in the archive. cp /etc/recipnet/recipnetd.conf /etc/recipnet/recipnetd.conf.rpmsave # Invent a name for the archive file. ARCHIVE=/root/recipnet-backup-`/bin/date +%Y-%m-%d`.tar.gz # Create an archive file. echo "Creating archive..." tar --create \ --gzip \ --absolute-names \ --totals \ --verbose \ --file $ARCHIVE \ --exclude /var/recipnet/db/snapshot\* \ /var/recipnet/db/ \ $RepBaseDirectory \ $SitMsgsSentDir \ $SitMsgsRecvDir \ $SitMsgsHeldDir \ $SitGrantFile \ /etc/recipnet/recipnetd.conf.rpmsave \ /etc/recipnet/sitesponsor.gif \ /var/www/html/recipnet/images/sitesponsor.gif RC=$? # Delete the temp configuration file. rm /etc/recipnet/recipnetd.conf.rpmsave # Report to the user and exit. if [ $RC -ne 0 ]; then echo "ERROR! tar returned $RC" exit 2 fi echo "The backup is complete. Archive written to:" echo $ARCHIVE