While we love WordPress for so many fantastic reasons, there is no denying the fact that it is prone to vulnerabilities when not properly handled and can result in severe damages.
So if you have a WordPress site, it’s essential that you take proper care to keep it away from all follies. One of the crucial maintenance steps in this regard is to back up your site regularly.
You may hold the notion that nothing can go wrong with your data when you have the automatic backing up system installed on your website. However, you do not know how and when things might go wrong.
So, always try to put an extra layer of security around the hard work that has taken so much of your time, effort, and money. It does not even take a minute to lose all your data (either because of a human or a technical error), and it can be incredibly intimidating to start things from scratch.
The best way to safeguard your data is to make a manual backup of your WordPress database from time-to-time. It might sound overwhelming in the beginning, but trust me, it’s worth every second of the time you will spend in the process.
This backup can come in handy in case your website gets hacked, and you find yourself locked out of your admin area. Since accessing the admin area at such times can be a significant challenge, using a plugin for your backup is entirely out of the question.
In today’s tutorial, let me tell you how to run a backup of your WordPress database without a plugin. But before that let’s understand the basics of the WordPress database.
Understanding the WordPress Database
WordPress is a database-driven PHP web application. So you have to individually backup the following to have a complete backup of your database.
- Your WordPress blog
- Your WordPress files
- WordPress MySQL database
- Root Configuration Files
Your WordPress blog will contain all the content that you have uploaded so far on your website. The WordPress files contain your WordPress web application files, plugin files, and theme files.
In the third one, you will have more sensitive information like the user information, passwords, content, WordPress plugins and themes settings, website settings, etc.
In the last one, you will backup various root configuration files like the
.htaccess –the server configuration file, Webmaster tool identification file such as googleCODE.html, BingSiteAuth.html, Wp-config.php, etc.
Knowing WordPress wp-config.php File
wp-config.php is a significant part of your website. It contains not only the database connection details but also several other important pieces of information like the debug options, WordPress security keys, and other similar data. The standard database contains 11 tables. These tables are as follows –
Different Ways Of Backup Without A Plugin
There are several ways to back up your database without a plugin. In this post, we will look at three different ways that you can use for your website.
They are –
- Scheduling automatic backup using the cPanel
- Creating a manual backup using the cPanel
- Creating a manual backup using the phpMyAdmin
1. Scheduling Automatic Backup Using cPanel
Most of the shared hosting providers offer cPanel where you can schedule an automatic backup of your website. By doing this you create an automated way to back up your site, so you can skip all the tedious steps of doing it on your own.
It will take you just a few minutes to make the settings. For that, you will first have to log in to your cPanel and look for the Cron Job icon.
You will see a new screen opening with the options to let you set the time and frequency of running your backup. Set it according to your requirements. It will look something like this.
In the command field, copy-paste the following command:
mysqldump –opt -Q -u dbusername –password=dbpassword dbname | gzip > /path-to-store-the-backup-file/db_backup.sql.gz
In the place of the
dbpassword write down your database user password. Use a pair of single quotes around your dbpassword for it to work properly.
In place of,
dbname write the name of the database that you want to back up. You will also have to replace the path-to-store-the-backup-file with the file path in your server where you want the backup to be saved.
And that’s it. If you want to reassure whether things have been done correctly or not, go ahead and test the corn job to see if it works.
Note: You can find the name of your WordPress database in the wp-config.php file, in the root of your WordPress.
2. Creating a Manual Backup Using the cPanel
To create a manual backup of your database, you will first have to log in to the control panel of your web host and select the Backup Wizard option under Files.
Under Backup Wizard you will find another backup option. In this section, you will see two different options for the backup. With one, you can have a complete backup of your database while the other lets you do a partial backup.
You may think it viable to get a full backup done, but there is a small problem with it. If you have a full backup, you will not be able to restore it while you are in the same host.
This step is handy if you migrate to another host and want to restore your database in the new host.
The partial backup, on the other hand, lets you restore your database within the same host. You can use this backup if your site gets infected by any foreign threat or gets down for various reasons.
No matter which backup you want, each will need you to backup four different sections.
- The home directory that consists of the site’s themes, plugins, and uploaded content.
- The MySQL database that consists of the site’s setup that saves your posts and comments.
- The emails forwarded and its configuration
- E-mail filters.
Go to each option individually and download them. Save them on your PC. You can also keep them safe in your hard drive. Once done, your data is safe and can later be restored whenever you need them.
3. Creating a manual backup using the phpMyAdmin
Generally, a WordPress hosting provider has their phpMyAdmin installed in their control panel. Hence a user can easily set their hands on the control panel and perform the tasks necessary for its maintenance.
To create a manual backup of your WordPress database using the phpMyAdmin, you will first have to log in to your cPanel. Now as you go down the page that will appear on your screen, you will find various options like Preferences, Mail, Files, Log, Security, etc.
One of these options is the Database option. Under this option called the phpMyAdmin. On clicking on this option, a new screen will appear on your window called the
phpMyAdmin .Now choose the WP database option on your left.
A list of tables will now appear that are part of the database. In the menu bar on the top of the screen, you will see several options like structure, SQL, Search, Query, etc. Look for the Export option and click on it. This will let you export /backup the database to a file.
You will now have two different options on your screen to export the database. One is the Quick option, and the other is the Custom option like in the image below.
The custom option gives you more control over what you choose to export and what not. So select the custom option. Here’s a screenshot of what you will get.
You will see a list of tables that exist in your WordPress database. You can select all of them or choose what you don’t want to be being exported. Generally its safe to pick all the items on the table.
On the image above, you will find the Save output to a file option under the Output section. Check this option and select utf-8 for “Character set of file”. For compression, you can select the zipped or gzipped option.
Now go down to the end of the page and select Go. You will now have different options to download your file. Depending on what you select you will either get a zipped or a gzipped format of your database.
That’s it. Your work is done.
Now since you know, several methods to backup your WordPress database let’s check out how these backups can be restored in case there is an emergency.
Restoring MySQL Database From A Backup
Restoring your MySQL Database from a backup is very simple. You can quickly get it done by using the phpMyAdmin. For that, you will first have to log in to your cPanel and go to the databases section. Now click on the phpMyAdmin icon.
On to your left, you will find a Menu with two different options. From there select the database where you want your backup to be imported.
Once you select the database, you will be directed to a new page with the structure of the selected database. Now select the Import option in the menu on the top of the page.
A new page will pop on your screen. Click on the browse button and select what you want to import from your computer. Now hit on the Go button for the process to be completed. Once done, a confirmation mail will appear on the screen saying that the import has been completed.
To be on the safer side, it is recommended that you regularly run a backup of your WordPress database. Especially when you update your website with a new theme setting, or add a plugin for added functionality.
You may also consider using a premium backup plugin like My WP Backup Pro to help you taking backup in multiple locations and easy to restore.
I hope this was helpful to you.