#!/bin/bash # Create key and copy it over # ssh-keygen -t dsa # cat /root/.ssh/id_dsa.pub | ssh $OLDPATH "cat >> /root/.ssh/authorized_keys" # Change Cpanel Settings #echo maildir=0 >> /var/cpanel/cpanel.config #echo mysqloldpass=1 >> /var/cpanel/cpanel.config OPTS="-avzxlH --progress -e ssh" echo -n "What is the old server's IP? " read OLDIP #Match Software Versions and get all customer packages rsync ${OPTS} ${OLDIP}:/var/cpanel/easy/apache/ /var/cpanel/easy/apache/ rsync ${OPTS} ${OLDIP}:/var/cpanel/packages/ /var/cpanel/packages/ rsync ${OPTS} ${OLDIP}:/var/cpanel/features/ /var/cpanel/features/ # Find out old server mysql version RSQL=$(ssh ${OLDIP} "mysqladmin version | awk '/Server\ version/ {print $3}' | cut -d '-' -f 1") LSQL=$(ssh ${OLDIP} "mysqladmin version | awk '/Server\ version/ {print $3}' | cut -d '-' -f 1") # Downgrade if necessary if [[ "$RSQL" -lt "$LSQL" ]]; then perl -pi -e 's/mysql-version=5.0/mysql-version=4.1/g' /var/cpanel/cpanel.config mysql -e 'drop database horde'; mysql -e 'drop database roundcube' for each in cphulkd eximstats horde leechprotect modsec roundcube; do ssh 72.52.150.127 "mysqldump --compatible=mysql40 $each" > /home/temp/$each.sql; done /scripts/mysqlup --force for each in horde roundcube; do mysql -e "create database $each"; done for each in horde roundcube cphulkd eximstats leechprotect modsec; do mysql $each < /home/temp/$each.sql; done fi /scripts/easyapache --build #Package Accounts ssh ${OLDIP} "for USER in `ls -A /var/cpanel/users`; do /scripts/pkgacct --skiphomedir $USER; done" #Copy files over scp ${OLDIP}:/home/cpmove-*.tar.gz /home/ #Restore cd /home for x in $(ls -A *.tar.gz | cut -d "-" -f 2 | cut -d "." -f 1); do /scripts/restorepkg $x; done echo "Copying data, this may take a while..." for acct in $(ls -A /var/cpanel/users); do rsync ${OPTS} ${OLDIP}:/home/${acct}/ /home/${acct}/ # SSL Certs rsync ${OPTS} ${OLDIP}:/usr/share/ssl/ usr/share/ssl/ # Root user directory rsync -avHx --exclude=.ssh/ ${OLDIP}:/root/ /root/ # Cpanel Skins rsync -av $OLDIP:/usr/local/cpanel/base/frontend/ /usr/local/cpanel/base/frontend/ echo "Rsync done, running updates..." /scripts/upcp #Doesn't hurt # Firewall config rsync -av $OLDIP:/etc/apf/ /etc/apf/ echo echo -e "Server migration done, please double check everything." echo