Applicable to:
- Plesk for Linux
Question
How to restore Plesk Onyx and Obsidian installation on a new Linux server after disaster ?
Answer
During a disaster recovery, it is necessary to set up a new Plesk instance and migrate all server settings and customers data from the old server.
If you prefer to let Plesk professionals handle the migration or upgrade job for you please check out Plesk professional services options on our website: https://www.plesk.com/professional-services/
Connect to the new server using SSH. It is assumed that the hard drive from the old server is mounted to the /old
directory on the new server.
Note: on the new server, the same version of Plesk as on the old one should be installed, and it should be licensed properly. Also, the same set of extensions should be installed on the new server.
-
Important: This step is only possible if the version of MySQL server matches for both the original and new server's one.
-
Start the MySQL server with the datadir parameter in
/etc/my.cnf
pointing to the MySQL database location on the old drive (/old/var/lib/mysql
):# cat /etc/my.cnf | grep datadir
datadir=/old/var/lib/mysqland dump the databases:
# MYSQL_PWD=`cat /old/etc/psa/.psa.shadow` mysql -u admin psa -Ns -e"select name from data_bases where type = 'mysql'" | while read dbname ; do MYSQL_PWD=`cat /old/etc/psa/.psa.shadow` mysqldump -u admin --databases $dbname > $dbname.sql ; done
-
Stop MySQL, revert the
datadir
parameter in/etc/my.cnf
to its original value:# service mysqld stop
# cat /etc/my.cnf | grep datadir
datadir=/var/lib/mysql -
Start MySQL and restore the databases:
# service mysqld start
# for f in *.sql ; do dbname=$(echo $f | sed -e 's/\(.sql\)$//g'); MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin -e "create database $dbname"; MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin -D$dbname < $f; echo "$dbname restored" ; done
-
-
Restore the Plesk databases from the available dump:
-
Stop the Plesk service:
# service psa stopall
-
Import the database dump:
# zcat /old/var/lib/psa/dumps/mysql.daily.dump.0.gz | MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin
-
-
Copy the Plesk database password file:
# cp -rpf /old/etc/psa/.psa.shadow /etc/psa/.psa.shadow
-
Copy the encryption key to the new server, set the correct permissions and restart MySQL service:
# cp /etc/psa/private/secret_key /etc/psa/private/secret_key.save
# cp -rpf /old/etc/psa/private/secret_key /etc/psa/private/secret_key
# chmod 0600 /etc/psa/private/secret_key
# chown psaadm:root /etc/psa/private/secret_key
# service mysqld restartNote: make sure that MySQL is accessible using
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin
-
Restore domain content:
# rsync -av /old/var/www/vhosts/ /var/www/vhosts/
Note: Wait until rsync process is finished
-
Restore Plesk system users:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin -Dpsa -Ns -e"select s.login, a.password, s.home, s.shell from sys_users s, accounts a where a.id = s.account_id" | awk '{ print "PSA_PASSWD=\x27" $2 "\x27 /usr/local/psa/admin/sbin/usermng --add-user --user=" $1 " --homedir=" $3 " --shell=" ($4?$4:"/bin/false")}' | sh -x
-
Restore the
mailnames
directory (mail content):# rsync -av /old/var/qmail/mailnames/ /var/qmail/mailnames/
# chown -R popuser:popuser /var/qmail/mailnames/* -
Restore scheduled
cron
tasks# rsync -av /old/var/spool/cron /var/spool/cron
-
For Plesk Onyx and Plesk 12.5, run fully automated reconfiguration utility:
# plesk repair all -y
Note: in case the domains have incorrect ownerships in
/var/www/vhosts/
directory, run the script below:# plesk db -Ne "select login,home from sys_users where mapped_to is null" | while read login home; do chown -R $login $home; done
-
Start the Plesk service:
# service psa start
Comments
1 comment
This is not clear, since disaster recovery inmho, means that the old server completely crashed and the data being restored is to a new server from a offsite full server backup. Nothing mentioned here if the old drive is not there nor is the old server? Also, what if there was no way of attaching the old drive to a new server.
Please provide instructions on how to restore to a new server with a offsite full backup, or a link to that page as I couldn't find one.
Please sign in to leave a comment.