X

How to backup a WordPress site on your VPS

Spread the love

In this tutorial, we will show you how to manually backup your WordPress site on your VPS. It is highly recommended that you make regular backups of your WordPress site so you can easily restore it if something unexpected happens, for example, if your site breaks because of a faulty plugin, it gets infected with malicious files, you accidentally delete the contents of our database and so on. In order to fully make a backup of your WordPress site, we will need to make a backup of your WordPress files and your WordPress database.

WordPress Files

First, we will make a backup of all of your WordPress site files.

To do so, you need to log in to your VPS via SSH.

Once logged in, you will need to navigate to your WordPress root directory. Depending on your server configuration this can be at a different location, for example, /var/www/html/wordpress/.

Your WordPress site consists of the following:

  • the WordPress core installation files (stored in the wp-admin directory).
  • the WordPress Themes and Plugins (stored in the wp-content directory).
  • libraries and third-party components (stored in the wp-includes directory).
  • Images and Files
  • JavaScript and PHP scripts
  • Additional files and static web pages

All of these together will generate your WordPress site, so it would be best to backup all of these files and directories.

It is usually enough to only copy your wp-content directory, as the contents of wp-admin and wp-includes are usually never modified, and you can always retrieve them from the original WordPress installer.

But, just so you can have a full working copy of our site, it would be a good idea to make a backup of all the WordPress files together.

So, if your WordPress root directory is located in /var/www/html/wordpress/, you can do this with the following command:

tar -cpzf wp-backup.tar.gz /var/www/html/wordpress/

This will create an archive file of all the WordPress files which generate your website.

WordPress Database

Your WordPress files alone are not enough if we want a complete backup of your website. All the information of your website, including your posts, comments, site configurations, user accounts and so on, is stored in your database.

You can make a full backup of your WordPress database with the following command:

mysqldump -u wp_user -p wp_database > wp_database_backup.sql

where “wp_user” is the name of the user of your WordPress database, and “wp_database” is the name of your database.

If you are not sure of the user, database name and password, you can find that information in the wp-config.php file inside your WordPress directory.

With this, you now have everything you need to successfully restore your WordPress site.

After you have successfully made a backup of both your WordPress files and database you can easily transfer them to your local computer via FTP or the other way around when you need to restore your website.

 

Of course, if you are one of our Linux Host Support customers, you don’t have to do any of this, simply ask our admins, sit back and relax. Our admins will make a backup of your WordPress site for you immediately.

PS. If you liked this post, on How to install Monica on Ubuntu 16.04, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.

Categories: Tutorials
admin:
Related Post