How to restore Plesk installation on a new Linux server after disaster


2016-11-16 12:58:41 UTC


2017-04-27 20:43:55 UTC


Was this article helpful?

Have more questions?

Submit a request

How to restore Plesk installation on a new Linux server after disaster

Applicable to:

  • Plesk for Linux


During disaster recovery, it is necessary to set up a new Plesk instance and migrate all server settings and customers data from the old server. For some reason, it is not possible to use the solution described in this article: How do I restore Plesk from a hard disk drive if the Operating System is broken and the HDD with the old installation is mounted to the new 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:

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.

  1. Important: This step is only possible if the version of MySQL server matches for both the original and new servers .

    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 ) and dump databases:

    # MYSQL_PWD=`cat /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 /etc/psa/.psa.shadow` mysqldump -u admin $dbname > $dbname.sql ; done

    Stop MySQL, revert the datadir parameter in /etc/my.cnf to its original value, start MySQL and restore the databases:

    # for f in *.sql ; do dbname=$(echo $f | sed -e 's/\\(.sql\\)*$//g'); MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin -D$dbname < $f; echo "$dbname restored" ; done
  2. Restore the Plesk database from the available dump:

    a) Stop the Plesk service:

    # /etc/init.d/psa stopall

    b) Start the MySQL server:

    # /etc/init.d/mysqld start

    c) 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
  3. Copy the Plesk database password file:

    # cp -rpf /old/etc/psa/.psa.shadow /etc/psa/.psa.shadow
  4. (For Plesk 11.x and later) Copy the encryption key to the new server:

    # cp /etc/psa/private/secret_key /etc/psa/private/
    # cp -rpf /old/etc/psa/private/secret_key /etc/psa/private/secret_key

    Note: it also may be necessary to chmod and chown the file:

    # chmod 0600 /etc/psa/private/secret_key
    # chown psaadm:root /etc/psa/private/secret_key

    These are the correct permissions for this file:

    [root@server ~]# stat /etc/psa/private/secret_key
    File: `/etc/psa/private/secret_key'
    Size: 16 Blocks: 8 IO Block: 4096 regular file
    Device: fd00h/64768d Inode: 49938531 Links: 1
    Access: (0600/-rw-------) Uid: ( 501/ psaadm) Gid: ( 0/ root)
    Access: 2014-07-14 17:35:51.000000000 +0200
    Modify: 2012-11-22 00:14:01.000000000 +0100
    Change: 2014-07-14 17:06:31.000000000 +0200

    Note: if after this, MySQL is not accessible with Plesk credentials ( MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin ), try restarting the MySQL server using service mysqld restart command.

  5. Alter the IP_Addresses table if the set of IP addresses assigned to the new server has changed.

  6. Restore domain content:

    # rsync -av /old/var/www/vhosts/ /var/www/vhosts/
  7. Restore Plesk system users:

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin -Dpsa -Ns -e"select s.login, a.password, s.home, from sys_users s, accounts a where = 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

    For Plesk 10.x and later, execute the following command:

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin -Dpsa -Ns -e"select s1.login, s2.login from sys_users s1 left join sys_users s2 on = s1.mapped_to where s2.login is not null" | awk '{print "/usr/local/psa/admin/sbin/usermng --map-user --user=" $1 " --mapped-to=" $2}' | sh -x
  8. Repair ownership on the virtual hosts' content to fix files and directories owned by non-existent users:

    For Plesk 10.x and 11.x :

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin -Dpsa -Ns -e"SELECT s.home, h.www_root, s.login FROM hosting h, sys_users s WHERE = h.sys_user_id" | while read home www_root login ; do content_uid=`stat --format=%u "$www_root"` ; find $home -uid $content_uid -exec chown $login '{}' + ; done

    For Plesk 9.x and earlier:

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin -Dpsa -Ns -e"SELECT home, login FROM sys_users" | while read home login ; do content_uid=`stat --format=%u "$home/httpdocs"` ; find $home -uid $content_uid -exec chown $login '{}' + ; done
  9. Restore SSL certificates:

    # cp -p  /old/usr/local/psa/var/certificates/* /usr/local/psa/var/certificates/
  10. Regenerate the web server configuration:

    For Plesk 8.x and 9.x :

    # /usr/local/psa/admin/sbin/websrvmng –a -v

    For Plesk 10.x :

    # /usr/local/psa/admin/sbin/httpdmng --reconfigure-all
  11. Restore content of the mailnames folder:

    # rsync -av /old/var/qmail/mailnames/ /var/qmail/mailnames/
    # chown -R popuser:popuser /var/qmail/mailnames/*
  12. Repair the mail configuration:

    # /usr/local/psa/admin/sbin/mchk –-with-spam
  13. Restore DNS zones:

    For Plesk 9.x and earlier :

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa -Ns -e  "select name from dns_zone" | awk '{ print "/usr/local/psa/admin/sbin/dnsmng update " $1 }' | sh -x

    For Plesk 10.x and newer :

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa -Ns -e  "select name from dns_zone" | awk '{ print "/usr/local/psa/admin/sbin/dnsmng --update " $1 }' | sh -x
  14. Start the Plesk service:

    # /etc/init.d/psa start
Have more questions? Submit a request
Please sign in to leave a comment.