MilesWeb Create WordPress Website Backup

MilesWeb Create WordPress Website Backup

In this article, we will learn How to create back up for a WordPress website?
MilesWeb didn’t provide any way to create a backup for our content. To create a WordPress website backup, we have two options, either we create a backup manually or we a can use SSH. We will cover both the methods in this article. 

Method 1: Create WordPress website backup manually

For our WordPress website backup, we need to back up for two. First one is the website files and the website database. We can create a file backup using File Manager. For the database backup, we will use phpMyAdmin. 

Step 1 - Create File Backup

To create the backup, for WordPress website files open the file manager. Navigate to the WordPress website folder or directory. If you are using a single domain hosting, then you can find all your website contents in the public_html directory. When we have multiple websites, we need to find the correct location for your website for which we need to create the backup. Open the correct directory. 

Next, we will use the File Manager to create a zip folder. Click on Select All button and then click on the “compress”. In the dialog, select the archive type, zip and finally click on the Compress File button. It will take some time based on the folder contents. Why Zip? We are using a Windows machine and in Windows 10 we can uncompress any zip file without the need of any additional software.

For us, a new Zip file is created with the name “.well-know.zip”. We need to rename the zip folder. We are renaming it to vlemon_in_17NOV2018_skdfksjdhf.zip. Keeping the backup file in public_html is risky. Let’s move it to the parent directory so only we can access it. To move the file, select the file and click on the move button. In the new dialog, select the location. Finally, click on the "Move File (s)" button to move the selected files.

After this, we will download the zip file. After download, we move or upload the backup file in any secure location. For example, external hard disk or cloud drives. To download the backup file, select the file and click on the download button.

We are done with the File backup. Next, we need to create a backup of our WordPress website database.

Step 2 - Create Database Backup

Database backup is very simple. We need to open phpMyAdmin and then we need to export the database used by our WordPress website. If you don’t know the database name, then you can find it inside WordPress config file “wp_config.php”. It is available in the WordPress website root directory.

To create the database backup first open phpMyAdmin. The phpMyAdmin is available at the control panel home page under the section Database. Open phpMyAdmin. Next, click on the database you want to export. Select the export tab and then click on the Go button. It will generate a “.sql” file save the “.sql” file.

If you want to know about the advanced backup option, you can check the phpMyAdmin tutorial series.
We are done with our WordPress website back up. It is very simple and easy way to create the backup for the WordPress website. But I am a little lazy, I don’t like recurring activities or tasks. Create manual backups will sometime boring and maybe leads to manual errors. To avoid this, we will use the second method to automate the above tasks.

Method 2: Create WordPress website backup using SSH

Before moving ahead, I am using you are done, everything which is available in this article. In the given article we are enabling SSH accessing for our MilesWeb shared hosting. Once you are done with the SSH setup, launch a new Putty session.

Step 1 - Create Database Backup

Once we are ready with our new Putty Session, we will first create the backup for our MySQL database. Again, if you want to know about the database, you can find it in the wp_conf.php file. We are interested in the database name, database user, and database password. To create a database backup, we need to execute the following command.

Code

mysqldump -u uqzrhmdl_vln -p uqzrhmdl_vln > vlemonn_in_db_bkp_17NOV2018.sql

In the above command, we are using mysqldump to export our database. In the command, we are providing the database username, and database name we need to export. I did not provide the password in the command. If you are not entering the password in the command, then in the next prompt we needed to provide the correct password. If the password is correct, the command will create a backup file with the provided name which “vlemonn_in_db_bkp_17NOV2018.sql” in my case. Our database backup is done. You can use the Control Panel File Manager to check the file contents. 

Step 2 - Create WordPress Website File Backup

Again, creating a folder backup with SSH is very easy. We need to provide the zip file or the output zip file name and the folder for which we need to create the backup. To create the backup for the public_html directory executes the following command.

Code

zip -r vlemonn_in_wp_bkp_17NOV2018.zip public_html/

The command is used to create a zip file with name “vlemonn_in_wp_bkp_17NOV2018.zip” for public_html. We are using -r to create a backup for all the contents inside public_html (-r is for recursive).
We have two commands 1 for database backup and another for file backup. Next, let’s check How to automate the above backup process.

Step 3 - Automate Script to back up

We already learned How to create a Database and Files Backup using SSH. Next, we need to automate it. To automate the backup, we will combine the above commands in a shell script file and use it with the Cron Job. The following command is the combined code for the final shell script.

 

Code

mysqldump -u uqzrhmdl_vln -p'[email protected]$$w0rd' uqzrhmdl_vln > vlemonn_in_db_bkp.sql
zip -r vlemonn_in_wp_bkp.zip public_html/
echo “Success” >> backup.log

To create the shell script file, we will use the nano editor. Execute the following command. It will open a new nano editor with file backup.sh. Paste the above command and save the file. Press Ctrl+O to write the changes and Ctrl+X to close the nano editor.

Code

nano backup.sh

Note: You need to edit the commands based on your environment.

After this, we need to change the execution permission for backup.sh file. Execute the following command. It will change the execute permission for backup.sh

Code

chmod 744 backup.sh

Next, we need to execute the following command to test our sh script. If it is executed successfully, we can use it with Cron Jobs.

Code

./backup.sh

If the execution completes without any error, we will create a Cron job. Cron Job will help us to create automatic backups.

Create a CRON Job. What is CRON?

CRON is a task scheduler for Linux. We will use it to create an automatic backup. To create a new CRON job we will use the following command. It will open the nano editor.

Code

EDITOR=nano VISUAL=nano crontab -e

After this, we need to add the following line. The following line will create a CRON job which executes in every one minute. We are using it only to demonstrate the automatic backup. You can keep it at least one for a day or one for a week.

Code

* * * * * ~/backup.sh

Add the above line and close the nano editor.
You can check the backup.log to check the execution status.

We are done with the automatic backup using SSH. We can still do lots of thing in our SSH script such as move back up in some other FTP servers, email alerts and so on. If you are interested to buy our premium SSH script you can buy it in only 5$. The premium script will help you to do the following thing.
1. Create automatic backup.
2. Upload backup to FTP or Cloud Drives.
3. Send alert emails.

0 Comments
Leave A Comment

Please login to post your valuable comments.

Join the newsletter

Get the latest vLemonn news first

share