Friday , December 20 2024

How to create a full backup of a WordPress site

I will not get tired of repeating how important it is to make backups of sites. This article describes 3 options for creating a backup – via ssh, via ftp, via the hosting provider’s panel, using a plugin.

Option 1: backup via ssh

1. Connect to the server (you can clarify the possibility of working via ssh with the technical support of your hosting provider)
ssh login:password@host

2. Go to the folder with the site. Let me remind you the commands just in case:
pwd – where am I?
cd /var/www/account/html/web/ – go to the site folder (you can request the full path to the site’s home directory from the hosting provider’s technical support)

3. Check the data for connecting to the database:
cat wp-config.php | grepDB

With this query, we are not looking at the entire file, but only the part that relates to the connection to the database. Sample output:

define( 'DB_NAME', 'mydbname' );
define( 'DB_USER', 'mydbuser' );
define( 'DB_PASSWORD', 'mydbpass' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8mb4' );
define( 'DB_COLLATE', '' );

4. Dump the database:

mysqldump -umydbuser -p mydbname > mydbdump.sql

The Enter password: window will appear
Enter the password you saw in the line define( ‘DB_PASSWORD’, ‘mydbpass’ );

5. Make a full backup of the site files:

tar -czf mybackup.tar.gz ./

Option 2: creating a backup via FTP

If the site is not tiny, then this process will be longer.

The action plan is similar:

1. Through a file manager (for example, FileZilla) connect to the server.

2. Go to the site folder. When connecting via FTP, we get into this folder directly, or we can find site folder in the list of folders.

3. Open the wp-config.php file, in this file try to find (you can use the Search) the lines DB_NAME, DB_USER, DB_PASSWORD.

4. Go to PhpMyAdmin (you can find a particular link in the hosting panel). For authorization, enter the data from the previous paragraph. In PhpMyAdmin, go to the “Export” tab and export the database, save the file to your computer.

5. Using FTP, download the folder with the site files to your computer.

Option 3: creating a backup through the Hosting Panel

This option cannot be described in detail. The easiest option is to request detailed instructions from the Technical support team of your hosting provider. On your own, you can find the “Backup” function in the Control Panel and make a current backup, save it to your account and download it to your computer – via the File Manager, or via FTP.

Option 4: creating a backup using WordPress plugins

There are several good plugins, this method is the most convenient for beginners. For example, to work with the Backup and Restore WordPress plugin, you do not have to bother with the settings. The disadvantage of this option is that you should not overload your site with a bunch of plugins. For small projects, this will not be so important.

Conclusion

You need to make backups more than once in your life, and not after the point of no return, when the backup is urgently needed. You can forget about your site for a while and find out after a few months that you forgot to pay for hosting, and the account has already been deleted beyond recovery. A site backup on your local computer will save you the expense of developing a new site. So, just do it!

About admin

Hi there! My name is Iryna, I am a web developer from Ukraine. While working on freelance projects I often face different technical issues and in this blog I publish articles on how to solve them. I am also interested in digital drawing and in this blog you will find brief tutorials that helped me and hopefully can help you as well.

Check Also

Css styles for WordPress admin in functions.php

If you need to add individual styles, and they are only a couple of lines, …

Leave a Reply

Your email address will not be published. Required fields are marked *