Regular backup is one of the most important task of every web administrator, and well done restoration from backup is priceless especially in the most critical situation. WordPress is no exception and because of that it is the key to learn how to create a backup and restore the website from it.
Creating backup
Conceptually, creating a WordPress backup takes two steps:
- creating the copy of source files – system files wp, themes, plugins, multimedia files (pictures, documents, videos, etc.)
- creating a copy of the database – data, the content of the wp itself
The backup of files is possible to do via FTP client, advanced user can use the access via Shell that allows for example zip the file before download. Create a backup of the whole directory of WordPress e.g. in a case for installation on the main domain it is the directory /web.
Create a database backup is from so-called dump, which means the export of the database, in the .sql file. You can download it in the administration of the domain in the secton Databases via button “Backups”, create a backup via phpmyadmin interface, or alternatively for larger databases you can use external SQL client or shell.
Restoring from backup
Process of restoration of WordPress is reverse of backup:
- upload the copy of core files to the hosting
- import copy of database to the new database
- edit the configuration of WordPress if necessary
Source files has to be uploaded to the “original” directory, on our hosting it is mostly /web. Upload is made via FTP client, in the case of zipped file you can use shell access for unpacking the archive in the /web directory.
Before the database restoration it is necessary to create a new database, import of the database is made via phpmyadmin interface, larger databases with the use of external SQL client or shell.
After restoration of source files and database it is necessary to connect new database with the installation of WordPress. This step is made by editing a file wp-config.php that is located in the /web directory.
You edit the following lines:
/** Name of the wordpress database*/
define('DB_NAME', 'database name');
/** username for database login*/
define('DB_USER', 'user name');
/** password for the wordpress database*/
define('DB_PASSWORD', 'password');
/** Address of the database server - can be found in the database administration */
define('DB_HOST', 'database server');
Except from manual backup of WordPress there are multiple ways for creating backups automatically or even periodically.