Plesk从垃圾场恢复

时间:2016-02-22 20:39:43

标签: wordpress centos plesk

我计划在专用服务器上重新安装CentOS 6系统,该服务器在Plesk 11.5托管程序中运行Wordpress网站。由于删除了php文件($#@ php php update ...),一些Plesk依赖文件已被删除,我无法访问Plesk管理面板(通过GUI备份文件)。我已将/var/lib/psa/dumps中的所有文件复制到FTP服务器。

According to this information默认情况下,所有备份文件都位于此处。如果我在重新安装后将它们复制到同一位置,是否可以完全恢复具有相应数据库的网站?

1 个答案:

答案 0 :(得分:0)

有关于如何在Plesk help center发生灾难后在另一台服务器上恢复Plesk for Linux安装的全面指南。

Plesk Onyx和Plesk 12.5

<强> 1。重要提示:只有当MySQL服务器的版本与原始服务器和新服务器的版本匹配时,才能执行此步骤。

使用/etc/my.cnf中的datadir参数启动MySQL服务器,该参数指向旧驱动器上的MySQL数据库位置(/ old / var / lib / mysql):

# cat /etc/my.cnf | grep datadir
datadir=/old/var/lib/mysql

并转储数据库:

# 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

停止MySQL,将/etc/my.cnf中的datadir参数恢复为原始值:

# service mysqld stop
# cat /etc/my.cnf | grep datadir
datadir=/var/lib/mysql

启动MySQL并恢复数据库:

# 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 -D$dbname < $f; echo "$dbname restored" ; done

2. 从可用的转储中恢复Plesk数据库:

停止Plesk服务:

# service psa stopall

导入数据库转储:

# zcat /old/var/lib/psa/dumps/mysql.daily.dump.0.gz | MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin

3. 复制Plesk数据库密码文件:

# cp -rpf /old/etc/psa/.psa.shadow /etc/psa/.psa.shadow

4. 将加密密钥复制到新服务器,设置正确的权限并重启MySQL服务:

# 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 restart

注意:确保使用MYSQL_PWD = cat /etc/psa/.psa.shadow mysql -u admin

可以访问MySQL

5. 恢复域名内容:

# rsync -av /old/var/www/vhosts/ /var/www/vhosts/

6. 恢复Plesk系统用户:

# 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

7. 恢复邮件名目录(邮件内容):

# rsync -av /old/var/qmail/mailnames/ /var/qmail/mailnames/
# chown -R popuser:popuser /var/qmail/mailnames/*

8. 对于Plesk Onyx和Plesk 12.5,运行全自动重新配置实用程序:

# plesk repair all -y

9。启动Plesk服务:

# service psa start

Plesk 9.x - 12.0

<强> 1。重要提示:只有当MySQL服务器的版本与原始服务器和新服务器的版本匹配时,才能执行此步骤。

使用/etc/my.cnf中的datadir参数启动MySQL服务器,该参数指向旧驱动器上的MySQL数据库位置(/ old / var / lib / mysql):

# cat /etc/my.cnf | grep datadir
datadir=/old/var/lib/mysql

并转储数据库:

# 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 --databases $dbname > $dbname.sql ; done

停止MySQL,将/etc/my.cnf中的datadir参数恢复为原始值:

# service mysqld stop
# cat /etc/my.cnf | grep datadir
datadir=/var/lib/mysql

启动MySQL并恢复数据库:

# 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 -D$dbname < $f; echo "$dbname restored" ; done

2. 从可用的转储中恢复Plesk数据库:

停止Plesk服务:

# service psa stopall

导入数据库转储:

# zcat /old/var/lib/psa/dumps/mysql.daily.dump.0.gz | MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin

3. 复制Plesk数据库密码文件:

# cp -rpf /old/etc/psa/.psa.shadow /etc/psa/.psa.shadow

4. 将加密密钥复制到新服务器:

# 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和chown文件:

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

这些是此文件的正确权限:

# 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)

注意:如果在此之后,使用Plesk凭证(MYSQL_PWD = cat /etc/psa/.psa.shadow mysql -u admin)无法访问MySQL,请尝试使用service mysqld restart命令重新启动MySQL服务器。

5. 恢复域名内容:

# rsync -av /old/var/www/vhosts/ /var/www/vhosts/

6. 恢复Plesk系统用户:

对于Plesk 11.x-12.0,执行以下命令:

# 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

对于Plesk 10.x,执行以下命令:

# 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 s2.id = 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

7. 恢复SSL证书:

# cp -p /old/usr/local/psa/var/certificates/* /usr/local/psa/var/certificates/

8. 恢复邮件名目录(邮件内容):

# rsync -av /old/var/qmail/mailnames/ /var/qmail/mailnames/
# chown -R popuser:popuser /var/qmail/mailnames/*

9。修复虚拟主机内容的所有权,以修复不存在的用户拥有的文件和目录:

# 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 s.id = 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

对于Plesk 9.x及更早版本:

# 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

10. 重新生成Web服务器配置:

对于Plesk 10.x-12.0:

# /usr/local/psa/admin/sbin/httpdmng --reconfigure-all

对于Plesk 8.x和9.x:

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

11。修复邮件配置:

# /usr/local/psa/admin/sbin/mchk –-with-spam

12。恢复DNS区域:

# 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

13. 启动Plesk服务:

# service psa start