Precautions for wordpress site backup and recovery

Source: Internet
Author: User
Tags file copy website server install wordpress mysql gui mysql gui tools phpmyadmin wordpress database wordpress version

I have previously discovered that the backup wordpress site is unavailable, the database is lost, or the image is gone. Taking the backup site and restoring it to a local virtual machine as an example, we need to pay attention to several issues.


1. wordpress database backup

By default, the simplest way to back up a wordpress database is to directly copy the database file, which is simple and fast. However, when I restore the database in my local virtual machine environment, I find that a table is missing.

Problem: wordpress often uses MySQL databases. The default engine used for data tables is InnoDB, and InnoDB is faster, but the problem is that it cannot directly copy files to back up the database or even delete it, this is also not possible because it is also related to the ibdata1 file. You can only use PHPMYADMIN or other MySQL GUI tools to export the database to the new database.

If you still want to back up the database using the file copy method, you only need to change the data table type to the commonly used MySIAM type through SQL statements, without affecting the normal use of wordpress.

The statement is as follows:

1. alter table 'WP _ commentmeta 'engine = MYISAM;
2. alter table 'WP _ comments' engine = MYISAM;
3. alter table 'WP _ links 'engine = MYISAM;
4. alter table 'WP _ options' engine = MYISAM;
5. alter table 'WP _ postmeta' engine = MYISAM;
6. alter table 'WP _ posts' engine = MYISAM;
7. alter table 'WP _ terms' engine = MYISAM;
8. alter table 'WP _ term_relationships 'engine = MYISAM;
9. alter table 'WP _ term_taxonomy' engine = MYISAM;
10. alter table 'WP _ usermeta 'engine = MYISAM;
11. alter table 'WP _ users' engine = MYISAM;

Remember, if there is a plug-in data table, remember to change it. Otherwise, the plug-in data cannot be found.

It seems that I have done it now, but I still cannot see the database table in phpmyadmin after I changed the database engine. What is the problem? After carefully checking the Directory, we found that the copied wordpress database folder and file users and user groups were incorrect. The original user and group on the server were both nobody and changed to root, currently, all other normal database file users and groups are in mysql, and it is easy to solve the problem by finding the file.

Root # chown-R mysql: mysql yourwordpressdb

This time the database is done.

2. The wordpress site is still inaccessible and the error 404 is displayed.

If the database and user name change, edit the wp-config.php and make sure it is set to the correct property value.

If you want to test the function before the transfer, you must temporarily change the "siteurl" and "home" values in the "wp_options" database table item (which can be modified using a tool similar to phpMyAdmin ).

If you have set any rewrites (permanent link), you need to disable. htaccess, and then reconfigure the permanent link.

In this case, the system still reports the 404 error when directly accessing the page or index. php, but you can access the background through the local website.

Http: // localhost/yourwordpress/wp-admin

Set the background settings and fixed links back to the default status. Try again and find that your wordpress has been restored to the normal status.

Data backup and recovery

1. Backup

======================================

Assume that the installation path on the wordpress server is/var/www/html/wordpress, and the backup directory is/home/quietheart/backup_wordpress. Back up data as follows:

1) back up wordpress:

Back up the content in the "wp-content" subdirectory of the wordpress installation directory on the website server, as well as the content of the "wp-config.php" file, and other content you modified (if any ). The "wp-content" subdirectory contains plug-ins and uploaded attachments; the content in the wp-config.php is some configuration information such as what database to link and so on.

The process is as follows:

# Cd/var/www/html/wordpress

# Tar-czvf/home/quietheart/backup_wordpress/wp-content.tgz wp-content

# Cp wp-config.php/home/quietheart/backup_wordpress

 

2) back up wordpress database content:

Two methods: (The first method is used currently)

First, use the plug-in "WordPress Database Backup" to directly generate a Backup Database.

The second method is to use the mysql command (currently, it is not easy to use, but only provides one idea ):

The practice process is as follows:

# Mysqldump-u quietheart-p123 -- databases wordpress_db> mysql. wordpress

After practice, this method does not seem to work. The comparison shows that the contents of the database files generated by the two methods are different. In addition, phpmyadmin is a commonly used database backup tool.

 

In summary, we can see that the backup content mainly includes: 1) compressed package of the wp-content directory. 2) wordpress database. 3) modify the file like wp-config.php.

 

2. Restore

======================================

Assume that the previously backed up wordpress program is restored on another host, and the installation path is/var/www/html/wordpress,

The backup path of the data to be restored is/home/quietheart/backup_wordpress.

The general process is as follows:

1) Download the wordpress program of the same version you have backed up.

The download URL can be found at www.wordpress.org.

2) decompress the downloaded wordpress and copy the previously backed up wp-content to the network directory.

3) Create an empty database (name should be the same as the backup database ).

4) install wordpress

5) import the backup database

 

The specific steps are as follows:

# Cd/home/quietheart/tmpTrans

# Wget http://wordpress.org/latest.tar.gz

# Tar-xzvf latest.tar.gz

# [-D/var/www/html/wordpress2] & rm-rf/var/www/html/wordpress2

# Mv wordpress/var/www/html/wordpress2

# Firefox 10.1.2.213/wordpress2/wp-admin/install. php

... Add necessary information to the open browser webpage...

# Mysql -- default-character-set = utf8-uquietheart-p quietheart <quietheart_wp_20151126_137. SQL

Here, if we have installed wordpress, it is no longer a problem to understand the meaning of each command during restoration. Pai_^

Note:

Latest.tar.gz should be the same as the wordpress version you want to restore.

Before installing with firefox, make sure that the database name in the wp-config.php file is consistent with the name used for the import just now (quietheart ).

In addition, if you do not use the "-- default-character-set = utf8" option during mysql recovery, garbled characters will appear.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.