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/mysql -
Create dumps of all MySQL 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 and 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 database from the latest available dump:
-
Stop the Plesk service:
# service psa stopall
-
Start the mysql server:
# service mysqld start
-
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…