Pre-migration steps (DNS)
rsync -avHl /var/named/ /home/named.backup/ sed -i -e "s/14400/600/" /var/named/*.db newserial=$(date +%Y%m%d%H) sed -i -e "s/[0-9]\{10\}/$newserial/" /var/named/*.db rndc reload
For customers with a large number of domains you can use the find command.
cd /var/named find . -name "*.db" -exec sed -i -e "s/TTL\ 14400/TTL\ 600/" {} \; newserial=$(date +%Y%m%d%H) find . -name "*.db" -exec sed -i -e "s/[0-9]\{10\}/$newserial/" {} \; rndc reload
Shared accounts
On our name servers it is best to create a text file with the list of domains.
for domain in `cat domains.txt `; do sed -i -e "s/TTL\ 20h/TTL\ 600/" /var/named/$domain.db; done newserial=$(date +%Y%m%d%H) for domain in `cat domains.txt `; do sed -i -e "s/[0-9]\{10\}/$newserial/" /var/named/$domain.db; done for domain in `cat domains.txt `; do sudo /usr/sbin/rndc reload $domain; done
Set up ssh key
ssh-keygen -t rsa cat /root/.ssh/id_rsa.pub | ssh root<newhost> 'read key ; mkdir -p ~/.ssh ; echo "$key" >> ~/.ssh/authorized_keys'
Package Accounts
for i in $(/bin/ls -A /var/cpanel/users/);do /scripts/pkgacct $i /home/temp; done
To skip home dirs:
for i in $(/bin/ls -A /var/cpanel/users/);do /scripts/pkgacct --skiphomedir $i; done
Add “–skipacctdb” to skip databases.
To split the packaging process run this:
for i in $(/bin/ls -A /var/cpanel/users/[a-j]*| cut -d "/" -f 5);do /scripts/pkgacct $i; done for i in $(/bin/ls -A /var/cpanel/users/[k-z]*| cut -d "/" -f 5);do /scripts/pkgacct $i; done
Migrate only certain accounts:
while read domain; do ACCT=$(grep -l DNS=$domain /var/cpanel/users/*); /scripts/pkgacct `basename $ACCT`; done < domains_to_move.txt while read domain; do ACCT=$(grep -l DNS=$domain /var/cpanel/users/*); echo $domain `basename $ACCT`; done < domains_to_move.txt
FTP files:
ncftpget -R -u user -p pass host_name . public_html/ wget -c -r -nH ftp://user:pass@host.net:/
lftp: set ftp:ssl-allow no mirror . .
Restore Accounts
Note: It is generally advised to run easyapache before restoring the accounts.
cd /home for x in $(/bin/ls -A *.tar.gz | cut -d "-" -f 2 | cut -d "." -f 1); do /scripts/restorepkg $x; done
Prep for final rsync
for service in crond atd exim httpd cpanel courier-imap courier-authlib dovecot named pure-ftpd proftpd; do /etc/init.d/$service stop; done
Put up maintenance page:
cd /usr/local/apache/htdocs/moving.page
index.html contents:
cat << EOF > index.html <html> <head> <title>Maintenance</title> </head> <body style="margin:50px 0px; padding:0px; text-align:center; background: LightGray;"> <p>Notice:</p> <div id="content" style="border: 1px solid; width: 500px; margin:0px auto; padding:15px; background: Pink;"> <P class='quote'>This site is currently under maintenance. Please try again later.</div> </body> </html> EOF
Start up new http server:
python -m SimpleHTTPServer 80
Rsync Account Data
echo "x.x.x.x oldserver" > /etc/hosts for acct in $(/bin/ls -A /var/cpanel/users); do rsync -avzHPpl -e "ssh -c arcfour" --delete root@oldserver:/home/$acct/ /home/$acct/; done ssh oldserver "mysql -Bse 'show databases'" | egrep -v "information_schema|cphulkd|eximstats|leechprotect|tmp|logaholic|modsec|mysql" > dbs.txt for db in `cat dbs.txt `; do mysql -e "create database $db" 2>/dev/null; done for db in `cat dbs.txt `; do echo $db && ssh oldserver "mysqldump --opt --skip-lock-tables $db" | mysql $db; done rsync from a plesk server: mypass=`ssh oldserver cat /etc/psa/.psa.shadow` ssh oldserver "mysql -u admin -p'$mypass' -Bse 'show databases'" | egrep -v "information_schema|cphulkd|eximstats|leechprotect|tmp|logaholic|modsec|mysql" > dbs.txt for db in `cat dbs.txt `; do mysql -e "create database $db" 2>/dev/null; done for db in `cat dbs.txt `; do echo $db && ssh oldserver "mysqldump --opt --skip-lock-tables -u admin -p'$mypass' $db" | mysql $db; done push method: for acct in $(/bin/ls -A /var/cpanel/users); do rsync -avzHl -e ssh /home/$acct/ root@$newserver:/home/$acct/; done for db in $(mysql -Bse 'show databases' | egrep -v "information_schema|cphulkd|eximstats|leechprotect|tmp|logaholic|modsec|mysql"); do mysqldump --add-drop-database --databases $db | ssh $newserver "mysql"; done
Update Zone Files
Copy the zone files from the new server to the old server.
cd /var/named scp *.db oldserver:/var/named/
ssh oldserver
cd /var/named newserial=$(date +%Y%m%d%H) sed -i -e "s/[0-9]\{10\}/$newserial/" /var/named/*.db /etc/init.d/named restart