How to Back Up WordPress Database and Files

Published: 3 Mar 2023

There are two parts to every WordPress website: 1) the database, which stores the contents of posts, as well as categories, tags, comments, and various settings, and 2) the files for themes, plugins, and WordPress itself. This guide shows how to back up both of these, to make sure you can restore your website if anything goes wrong.

WordPress database backup

Log into cPanel.

On the cPanel main page, find the section named "Databases".

Tip: By default the Databases section is located close to the bottom of the page. You can rearrange the individual sections and move this one to the top (just drag and drop).

The Databases section shows four links. Click on "phpMyAdmin".

Find the website's database in the left sidebar menu (there may be multiple databases listed).

Click on the database name. A list of tables should appear on the right side.

Important: Do not select any particular table. You want to back up the entire database, not just one table.

In the top horizontal menu, click on "Export" (it is approximately in the middle).

The next page lets you select an export method. Select "Custom – display all possible options".

Select "SQL" as format (unless you want to get the data in a different format – SQL format is easiest to restore if you ever need to do that).

Click the "Go" button.

More options will appear on the page.

You can again specify which tables to include in the backup – usually you want them all, so make sure all are selected.

The next section is "Output".

Keep "Save output to a file" selected.

On the next row you can customize the file name. It is good to include the date in the file name, so you always know which file to use when you have multiple backup files. If you update and back up your website more often, you may also want to include the time in the file name.

I use only date and for that you need to change the row labeled "File name template:" which says "@DATABASE@" to "@DATABASE@-%y%m%d". The file name will be your-database-name_yymmdd.sql, for example mysite_230319.sql if your database name is "mysite" and the date of backup is 19 March June 2022.

Keep the next option ("Character set of the file") set to "utf8", unless you know what you are doing.

You may choose compression to make the file smaller. But if your website is not very big (less than 200-300 posts), this is not needed. Use this later when you find your backup file size becomes too big.

The next section is "Format", which you have already seen. Keep "SQL" unless you want something else.

The next section is "Format-specific options". Unless you know what you are doing, keep everything as it is by default. One part which you should pay attention to is the three options in the end of this section: "structure", "data" and "structure and data". Make sure "structure and data" is selected.

  • Selecting only "structure" would only include the initial empty tables, without your posts and other data, so it is quite useless.
  • Selecting only "data" would only include your content, but you would only be able to use it with existing WordPress database.
  • Selecting "structure and data" will enable you to restore the full working WordPress database without needing anything else.

You can keep the remaining options as they are (unless you know what you are doing).

Click the "Go" button in the bottom. The download of the backup file should start.

If the above sounds complicated and long, don't worry. Once you have done it a few times, it will start to feel very simple. Basically you only add the "-%y%m%d" to the file name and you're done (and even that is not really needed).

WordPress files backup

You don't need to back up the core WordPress files, because they are always available from the wordpress.org/download/ page and there are frequent WordPress updates, which will change some of these files anyway.

The things you need to back up are your theme files (if you are using your own theme or if you have made own modifications to a publicly available theme) and any uploads and non-WordPress content which you may have on your server.

The theme files can be found in wp-content/themes/[your-theme-folder-name]/. You only need to back up these when you make any changes to your theme. Adding or editing posts, categories or tags does not affect your theme.

By default, the files uploaded via the wp-admin post editing interface are stored in wp-content/uploads/ and sometimes organized in year and month subfolders (you can turn this on or off in wp-admin/Settings/Media). However, your pictures, video and other files can be stored in another location if you have changed the default uploads directory in wp-config.php.

Files which you have uploaded manually (not via wp-admin) may also be stored on other locations – make sure you keep this consistent and remember the location when adding files.

WordPress settings

Some settings are stored in the database (in the options, which may be named "wp_options" or "[yourprefix]_options"). These are generally settings which you change in the wp-admin "Settings" area. You will have a backup of these when you do the database backup (make sure you select the entire database when doing the backup; not just one table).

Other important settings are stored in files, particularly wp-config.php and .htaccess. It is always wise to have backup copies of these files. You won't change them often, so it's not a problem.

By remaining on this website or using its content, you confirm that you have read and agree with the Terms of Use Agreement.

We are not liable for any damages resulting from using this website. Any information may be inaccurate or incomplete. See full Limitation of Liability.

Content may include affiliate links, which means we may earn commission if you buy on the linked website. See full Affiliate and Referral Disclosure.

We use cookies and similar technology to improve user experience and analyze traffic. See full Cookie Policy.

See also Privacy Policy on how we collect and handle user data.

© 2024 WPDir