I will show you the simplest method to manually backup database and all website files from your server and save them locally on your machine.

We’ll connect to the droplet using the terminal and zip entire HTML directory and save it to the same directory.   We’ll download the zip file using the browser and then delete it from the server. In the same way, we’ll dump the database as SQL file, download it from the browser and finally delete it from the server.

Here is how I manually backup my files and database from my server in simplecloudhosting.net and saved to local machine using Terminal.

Step 1: 

Open Terminal (Mac) or Putty (Windows) and connect to your terminal by running the following command and enter the password when prompted.

ssh yourUsername@yourIPAddress

Your command will look like ssh amar@138.197.84.94

Step 2: 

Navigate to /var/www/html directory using the command cd /var/www/html

Step 3: 

You need to follow this step only when you’re taking backup for the first time. In this step, we’re installing a utility to zip the files. Ignore this step if zip utility is already installed and proceed to step 4.

Run the following commands to install zip utility. Press  Y      when prompted.

sudo apt install yum
sudo yum install zip

Step 4: 

It’s time to take the actual backup by running the following command. It would take 2-10 minutes to zip your entire site depending on the size of files. Don’t panic and stay calm until it does its work

sudo zip -r /var/www/html/files-backup.zip /var/www/html/

Your backup will be saved with name  files-backup.zip  and you can download the backup file by opening www.domain-name.com/files-backup.zip 

Step 5: 

For security reasons, you should delete the zip file immediately after downloading the zip file. Run the below command to delete the backup file from the server.

sudo rm files-backup.zip

We have successfully downloaded your entire website files and saved it on the local machine. Still, we need to back up the database to complete the process.

Step 6:

We’ll back up the entire database as an SQL file which can be used to restore again if needed. To back up your database, run the below command with required changes.

sudo mysqldump -u mysql_username -p database_name > database-backup.sql

Before running this command, make sure you change mysql_username and database_name you need to back up. Along with them you also need to enter the MySQL password (if any) when prompted.

You can get all these 3 details from your wp-config.php file. To open it, run sudo nano wp-config.php command

Get MySQL username, password and database name from wp-config.php file

Step 7:

Download the database backup by opening  www.domain-name.com/database-backup.sql  from your browser.

Step 8:

Again for security reasons, you need to delete the database-backup.sql file by running the following command

sudo rm database-backup.sql

That’s it you’re done manually taking backup of files and database from your server. Log out and close the terminal.

What’s next?

Make sure you  deleted both files from the server by opening  www.domain-name.com/files-backup.zip  and  www.domain-name.com/database-backup.sql  where both URL’s will land you in 404 page.

Repeat all steps except Step 3 every day for regular backups.

You can also upload those two files to Dropbox or Google Drive for better safety.

Alert: For Control Panel Help & Tutorials, click here: Panel Tutorials
Was this answer helpful? 0 Users Found This Useful (0 Votes)