Question
How to restore a Plesk server on a new Linux server from file system?
Answer
To restore a Plesk server on another Linux server with the following steps, the new server must meet the following requirements:
-
Same versions as on old server of the following:
- operating system
- Plesk version
- MySQL or MariaDB
-
A valid Plesk license is installed
-
Same set of Plesk extensions installed
Note: Several Plesk extensions, for example
Plesk Premium Email
andPlesk Email Security
need additional setup. Make sure all necessary packages of extensionsare installed in Extensions > <extension_name> > Open.
If you prefer to let Plesk professionals handle the restoration, contact the Plesk professional services here: https://www.plesk.com/professional-services/
In the following steps, it is assumed that the hard drive from the old server is mounted to the directory /old
on the new server.
-
Connect to the new Linux server using SSH
-
Create database backups with old server's data directory:
2.1. Start the MySQL/MariaDB 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/mysql2.2. Create dumps of all MySQL/MariaDB 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
2.3. Stop MySQL/MariaDB service 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/mysql2.4. Start MySQL/MariaDB service 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:
3.1. Stop the Plesk service:
# service psa stopall
3.2. Start the database server:
# service mysqld start
3.3. 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: Verify the database server is accessible after this step, with the command
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin
-
Restore domain content:
# rsync -av /old/var/www/vhosts/ /var/www/vhosts/
Note: Process further only after rsync process is finished
-
Restore Plesk system…