S
sieb@
Guest
Ok, after months of testing, I have finally finished a friendly automated backup script for PSA. I have most of the rough edges polished so it should be ok for mutual consumption. This is simple so people other than me can figure it out. I know there are other fancy perl scripts and such floating around but thats too much work.
I like keeping things simple on my servers, makes less that I have to remember to configure if I have to restore. Just copy the script and put it in a psadump.sh file.
What it does?
-Creates a dir based on the current date to house the dump files
-creates a PSADump for disaster recovery
-creates manual archives of Vhosts and Mailnames dirs for off-hand restores
-capable of migrating dumps to an NFS server
-clears Qmail queues
-writes most output to a temp log file
-emails temp logfile to the admin
I set this script is run twice a week via a cron entry I have in PSA under Root (sh /home/backup/psadump.sh). I also have rudamentary NFS commands added in here, that I am still testing, to offload dumps to an NFS server. You will have to configure your server for NFS so I commented the NFS stuff out for you.
You will have to remember to go in every other month or so and clean out past dumps. I like leaving them there just so I have a second copy somewhere, though this will cause issues with NFS (hence the still testing).
You will also have to create the /home/backup folder if thats where you want them (its my biggest partition so I leave them there), and remember to change the email address. I set the script to 777, but 700 should work.
Also, the end of this script purges the Qmail queue using qmHandle, so you will need that installed too (everyone should! http://sourceforge.net/projects/qmhandle ). This is to clear spam and **** out of my remote queues. I assume that if its still in there at 2am, even after I force Qmail to send everything, then its not going to be leaving on its own.
The log file it creates only has the PSAdump output in it and the dumped mailanmes appended to it. I didnt do a verbose tar of the vhosts dir because that creates too much output. But if thats what you want, its there, just add a v to the tar options. I suppose if you have alot of users you should remove verbose tar for the mailnames also but again, thats up to you.
**I take no responsability if this borks your boxen.**
-----------------
#!/bin/bash
echo ***************************************
echo Initializing FULL PSA System Dump
echo -------------------------------------------------
cd /home/backup
mkdir $(date +%F)
cd /
.//usr/local/psa/bin/psadump -F -f /home/backup/$(date +%F) -z &> /home/backup/$(date +%F).log
sleep 5
echo ----------------------------------
echo Initializing Manual Dump
echo ----------------------------------
echo Dumping Website Directory
cd /home/backup/$(date +%F)
tar -czf vhosts.tar.gz /home/httpd/vhosts >> /home/backup/$(date +%F).log
echo ----------------------------------
echo Dumping Qmail Mailboxes
tar -czvf mailnames.tar.gz /var/qmail/mailnames >> /home/backup/$(date +%F).log
echo ----------------------------------
echo Dump Complete!
#echo Updating Remote NFS Backup
#echo This May Take A While
#echo --------------------------------
#mount 172.168.1.162:/nfs/00 /mnt/nfs
#cp -ur /home/backup /mnt/nfs
#cd /
#umount /mnt/nfs
#echo --------------------------------
#echo Remote Backup Complete
echo ----------------------------------
echo Clear Qmail Queues
echo ----------------------------------
cd /
cd /var/qmail/bin
./qmhandle -a
sleep 10
./qmhandle -D >> /home/backup/$(date +%F).log
echo DONE!
echo Mailing Logfile
cat /home/backup/$(date +%F).log | mail -s "Server Backup Log `date +%F`" changeme@foo.bar
echo ---------------------------------
echo Returning to Normal Operations
echo ---------------------------------
What it does?
-Creates a dir based on the current date to house the dump files
-creates a PSADump for disaster recovery
-creates manual archives of Vhosts and Mailnames dirs for off-hand restores
-capable of migrating dumps to an NFS server
-clears Qmail queues
-writes most output to a temp log file
-emails temp logfile to the admin
I set this script is run twice a week via a cron entry I have in PSA under Root (sh /home/backup/psadump.sh). I also have rudamentary NFS commands added in here, that I am still testing, to offload dumps to an NFS server. You will have to configure your server for NFS so I commented the NFS stuff out for you.
You will have to remember to go in every other month or so and clean out past dumps. I like leaving them there just so I have a second copy somewhere, though this will cause issues with NFS (hence the still testing).
You will also have to create the /home/backup folder if thats where you want them (its my biggest partition so I leave them there), and remember to change the email address. I set the script to 777, but 700 should work.
Also, the end of this script purges the Qmail queue using qmHandle, so you will need that installed too (everyone should! http://sourceforge.net/projects/qmhandle ). This is to clear spam and **** out of my remote queues. I assume that if its still in there at 2am, even after I force Qmail to send everything, then its not going to be leaving on its own.
The log file it creates only has the PSAdump output in it and the dumped mailanmes appended to it. I didnt do a verbose tar of the vhosts dir because that creates too much output. But if thats what you want, its there, just add a v to the tar options. I suppose if you have alot of users you should remove verbose tar for the mailnames also but again, thats up to you.
**I take no responsability if this borks your boxen.**
-----------------
#!/bin/bash
echo ***************************************
echo Initializing FULL PSA System Dump
echo -------------------------------------------------
cd /home/backup
mkdir $(date +%F)
cd /
.//usr/local/psa/bin/psadump -F -f /home/backup/$(date +%F) -z &> /home/backup/$(date +%F).log
sleep 5
echo ----------------------------------
echo Initializing Manual Dump
echo ----------------------------------
echo Dumping Website Directory
cd /home/backup/$(date +%F)
tar -czf vhosts.tar.gz /home/httpd/vhosts >> /home/backup/$(date +%F).log
echo ----------------------------------
echo Dumping Qmail Mailboxes
tar -czvf mailnames.tar.gz /var/qmail/mailnames >> /home/backup/$(date +%F).log
echo ----------------------------------
echo Dump Complete!
#echo Updating Remote NFS Backup
#echo This May Take A While
#echo --------------------------------
#mount 172.168.1.162:/nfs/00 /mnt/nfs
#cp -ur /home/backup /mnt/nfs
#cd /
#umount /mnt/nfs
#echo --------------------------------
#echo Remote Backup Complete
echo ----------------------------------
echo Clear Qmail Queues
echo ----------------------------------
cd /
cd /var/qmail/bin
./qmhandle -a
sleep 10
./qmhandle -D >> /home/backup/$(date +%F).log
echo DONE!
echo Mailing Logfile
cat /home/backup/$(date +%F).log | mail -s "Server Backup Log `date +%F`" changeme@foo.bar
echo ---------------------------------
echo Returning to Normal Operations
echo ---------------------------------