If you’re an individual blogger, your website is your pride and joy, and in some cases, your livelihood depends on it. If you’re an organization, your website is the face of your company in the digital world. Keeping your website ship-shape and running at all times is an essential aspect of website maintenance.
Keeping a recent backup of your website is as important as maintaining it. Whether your website gets hacked, is involved in an attack or gets corrupted in any way, restoring a backup is the best way to get everything back online—fast. You can back up your website in many ways. Some common methods of backing up a website include:
- Using a backup plugin to back up your website and database automatically
- Using a backup service from your hosting provider
- Manually backing up your website and database
This article is the first of our multi-part series about WordPress security, backups and restoration and will deal with backing up your WordPress website manually. Although you can also back up your website automatically using a plugin, it is always good to know how you can perform a manual backup without a working plugin.
Getting ready to take a backup of your website manually
Note that there are dozens of ways to take a backup of your website. This article will cover the simplest method of taking a manual backup that is easy for most users. Here’s what you need:
- Administrative access to your site files and database
- Administrative access to cPanel, File Manager and phpMyAdmin
Preparing your computer or server drive for backups
Once you are sure that you have administrative access to the items listed above, it is time to set up your computer for taking an offline backup. Backups are often taken on your local computer or a remote server. All you need to do is create the following folder structure:
- Create a new folder called Backup
- Within the backup folder, create a folder with the date you wish to backup (e.g., today’s date). This is important, so you know what date the backup is from when you restore the files.
- Create two folders within this folder called Database and Site Files
Once complete, this is what your directory structure will look like.
Note: You can create any directory structure you want. I just made this directory structure as an example to enhance clarity.
Backing up your website database
It is essential to back up your website’s database as all your blog entries and pages are controlled by the database. Additionally, all the users, plugins, tables, and other data of your website are stored in the database. WordPress often uses a database called MySQL, which is extremely easy to back up. Here’s what you need to do:
1. Log in to cPanel from your browser with your username and password (If you do not know what cPanel is, contact your hosting provider for details). cPanel is the default administrative console for your hosting, provided to you by your web host.
2. Once you’ve logged in, you will see the following screen. Click on phpMyAdmin. phpMyAdmin opens in a new browser window.
3. Once phpMyAdmin has opened in a new browser window, choose your website database from the list of databases. Once you click the appropriate database, you will see all the database tables on the right-hand panel. Click the Export tab.
Note: In some configurations, you might be asked to scroll to the bottom of the list of tables and click the “Select All” checkbox before you click on the Export tab
Note: If you do not know which database you need to download, go back to the File Manager and browse public_html> wp-config.php. Right-click on the file and select View. Search for
the value in the DB_NAME variable is the name of your database. This is how it will look in wp_config:
4. From the Exporting databases from the current server tab, click Quick, set the format as SQL and click Go to export the database.
5. Once the download is complete, you will see a file with a .sql extension in your downloads folder. Move this file to your Database folder.
Note: In some cases, your database might not download and display the database contents in your phpMyAdmin console. If this happens, copy all that is displayed and paste it into a new text document. Name the file Database. Once saved, rename the file to database.sql and move it to the Database folder.
Exporting your website files
Once you have successfully exported your website database, it is time to export all your website files. Here’s how you can do this:
1. Login to cPanel with your username and password
2. Click on Files > File Manager
3. From the File Manager list of directories, select public_html
4. Right-click on public_html and choose Compress
5. From the Compress pop-up, choose Zip Archive and click Compress File (s). Once you do, you will see a dialog that showcases the progress of creating an archive of this directory in a file called public_html.zip. Note that this might take some time to complete and depends on the size of your website and the computational power of your server. In most powerful VPS servers such as those from Pack Web Hosting, this should not take more than a minute.
On completion, you will see the Compression Results dialog. Click Close.
6. Once the zip file has been created, right-click on the file name and click Download.
Once the zip file has been downloaded, move it to the Site Files folder. That’s it! You have successfully created a backup of your website files and database.
Note: If you cannot use cPanel to download the website files, you can use FTP or SFTP to download these files. FTP or File Transfer Protocol is a way to get files from a remote server. You will require an FTP client such as CuteFTP, FileZilla, WS_FTP Professional, Transmit or others to download these files.
Note: You can also use the Command Prompt or Terminal to connect to your website via FTP, but that requires an understanding of FTP commands and can be difficult for first-time users.
Using SFTP/FTP to download website files
You can easily use FTP to download the website files. Here’s what you need to do:
1. Download and install your favourite FTP client or use the terminal if you wish to
2. Set your local directory to Site Files. Here is how you can do it in FileZilla
3. Add the credentials to your FTP site. In FileZilla, you can do this using the Site Manager. In this, Host is your website address. Leave Port blank. Login Type is to be set to Normal. Enter your username and password and click OK to save this information.
4. Once you click OK, FileZilla will connect to the site.
5. Drag/drop the public_html directory onto the Site Files folder or right-click on public_html and choose Download
This is what the download process will look like in FileZilla.
Once the download is complete, all the files will be downloaded to your drive. Verify that the folder has all the files.
Note: If you are using the terminal in Linux, you can use the wget command to get all the files in the public_html folder. If you are using Windows, you can use wget using PowerShell. Here’s how:
Caution: Before you continue, understand that entering a command incorrectly in the terminal/PowerShell can permanently damage your WordPress installation. Ensure that you know what you’re doing before you attempt this.
- CD into the Site Files folder by typing the directory path you created for your backup. For example, this is the path I created: cd “Backup/20 July 2021/Site Files/”. Replace the part in quotes with the directory structure you created.
wget -r -nH --cut-dirs=5 -nc ftp://user:pass@server//absolute/path/to/directory
here is what the switches in this command mean:
- -nH avoids the creation of a directory with the server’s name
- -nc skips duplicate files (files that exist)
- –cut-dirs=5 This takes the content of /absolute/path/to/directory and puts it in the directory from where you launch wget. 5 is used to filter out the 5 directories of the path. // refers to an extra component
Note: You can use ncftp, wget, lftp, mirror or any other command of your choice to copy the contents of the entire directory to your local machine.
Using a plugin to backup your website
Whew! That took a while! If you think all of this is too technical for you, you can always use a plugin to backup your website. Plugins such as BackWPup, UpdraftPlus or All-in-one-WP Migration and many others can help you backup your WordPress website automatically. The procedure is simple and easy.
Using backup services provided by your hosting provider
Some hosting providers do automated backups as a part of their operations. But in most cases this is not part of the ‘hosting service’, but done as a goodwill gesture for contingency purposes. To put it simply, the hosting provider is not legally obligated to take and provide backups.
We at Pack Web Hosting, do take these measures purely as a goodwill gesture, but at the end of the day, the website owner should always have a copy of the website’s data on his local PC or laptop.