I would like to set up a secondary server as a "hot spare" for a cPanel server, so that in the case that the first one fails, the second can be easily swapped in simply by changing around some DNS records or updating a proxy server.

If there's a simple way to do this, I'm all for it. Otherwise, syncing manually is an option; the backup doesn't have to be up-to-the-second; syncing at regular intervals is sufficient.

Syncing MySQL is simple -- MySQL's built-in replication will take care of that. Syncing file systems is equally easy: just do an rsync pull every X minutes/hours/days to keep things fresh. Daemons like apache and bind can be easily reloaded after each rsync pull. Is there more to it?

If it's that simple, what files do I need to keep fresh? Obviously apache configuration, /home/* /var/named/* /etc/{passwd,shadow,group,gshadow}...

Has anyone tackled this problem before?

link|improve this question

feedback

1 Answer

up vote 1 down vote accepted

Pretty simple task actually. BE CAREFUL HOWEVER - there are a few directories you want to make sure that you dont overwrite unless you plan on taking the entire ip's over.

Also - what are these - Physical hosts or Virtual Servers? Reason I ask is the script I can give you to use - would work well - but you may need to edit a few lines out - or you could be up the creek if you plan on taking the same ip's ...

First - start from the BACKUP SERVER and create an SSH Key exchange between the servers. (if you need help here just ask... )

then from the backup server go to shell and type the following

mkdir /backupscript touch /backupscript/backupscript.sh chmod +x /backupscript/backupscript.sh nano /backupscript/backupscript.sh

PASTE THE FOLLOWING AFTER REPLACING x.x.x.x with your LIVE servers IP range:

rsync -vrplogDtH root@x.x.x.x:/var/cpanel /var
rsync -vrplogDtH root@x.x.x.x:/usr/local/apache/conf /usr/local/apache
rsync -vrplogDtH root@x.x.x.x:/usr/local/apache/domlogs /usr/local/apache
rsync -vrplogDtH root@x.x.x.x:/usr/local/frontpage /usr/local
rsync -vrplogDtH root@x.x.x.x:/var/named /var
rsync -vrplogDtH root@x.x.x.x:/var/ssl /var
rsync -vrplogDtH root@x.x.x.x:/var/spool/cron /var/spool
rsync -vrplogDtH root@x.x.x.x:/usr/share/ssl /usr/share
rsync -vrplogDtH root@x.x.x.x:/etc/vfilters /etc
rsync -vrplogDtH root@x.x.x.x:/etc/proftpd /etc
rsync -vrplogDtH root@x.x.x.x:/etc/vmail /etc
rsync -vrplogDtH root@x.x.x.x:/home/* /home
rsync -vrplogDtH root@x.x.x.x:/usr/local/cpanel /usr/local
rsync -vrplogDtH root@x.x.x.x:/usr/local/cpanel/3rdparty/mailman /usr/local/cpanel/3rdparty
rsync -vrplogDtH root@x.x.x.x:/var/log/bandwidth /var/log
rsync -vrplogDtH root@x.x.x.x:/root/.my.cnf /root
rsync -vrplogDtH root@x.x.x.x:/etc/httpd/conf/httpd.conf /etc/httpd/conf
rsync -vrplogDtH root@x.x.x.x:/etc/sysconfig/network /etc/sysconfig
rsync -vrplogDtH root@x.x.x.x:/etc/secondarymx /etc
rsync -vrplogDtH root@x.x.x.x:/etc/domainalias /etc
rsync -vrplogDtH root@x.x.x.x:/etc/valiases /etc
rsync -vrplogDtH root@x.x.x.x:/etc/vfilters /etc
rsync -vrplogDtH root@x.x.x.x:/etc/exim* /etc
rsync -vrplogDtH root@x.x.x.x:/etc/proftpd* /etc
rsync -vrplogDtH root@x.x.x.x:/etc/pure-ftpd* /etc
rsync -vrplogDtH root@x.x.x.x:/etc/passwd* /etc
rsync -vrplogDtH root@x.x.x.x:/etc/group* /etc
rsync -vrplogDtH root@x.x.x.x:/etc/*domain* /etc
rsync -vrplogDtH root@x.x.x.x:/etc/*named* /etc
rsync -vrplogDtH root@x.x.x.x:/etc/wwwacct.conf /etc
rsync -vrplogDtH root@x.x.x.x:/etc/cpupdate.conf /etc
rsync -vrplogDtH root@x.x.x.x:/etc/quota.conf /etc
rsync -vrplogDtH root@x.x.x.x:/etc/shadow* /etc
rsync -vrplogDtH root@x.x.x.x:/etc/*rndc* /etc
rsync -vrplogDtH root@x.x.x.x:/etc/ips* /etc
rsync -vrplogDtH root@x.x.x.x:/etc/ipaddrpool* /etc
rsync -vrplogDtH root@x.x.x.x:/etc/ssl /etc
rsync -vrplogDtH root@x.x.x.x:/etc/hosts /etc
rsync -vrplogDtH root@x.x.x.x:/etc/userdomains /etc
rsync -vrplogDtH root@x.x.x.x:/etc/trueuserdomains /etc
rsync -vrplogDtH root@x.x.x.x:/etc/trueuserowners /etc
rsync -vrplogDtH root@x.x.x.x:/etc/nameserverips /etc
rsync -vrplogDtH root@x.x.x.x:/etc/cpupdate.conf /etc
rsync -vrplogDtH root@x.x.x.x:/etc/demousers /etc
rsync -vrplogDtH root@x.x.x.x:/etc/localaliases /etc

* AGAIN MAKE SURE YOU REPLACE ALL OF THE x.x.x.x with the IP address of your LIVE server.

Hit Control X and save - overwriting the file

now simply setup a cronjob to run that script whenever you want to backup the system.

One last note - you can use this same script if you ever have to mount a failed drive / hacked system

of course you would change from root@x.x.x.x to the mounted drives location ie /old/...

AND Finally

if you turn off mysql on both systems and add this line

rsync -vrplogDtH root@x.x.x.x:/var/lib/mysql /var/lib

it will copy all of the mysql db's raw files

If you need help running the cron as well please do not hesitate to ask.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.