Here are the steps to backup VPS by using SSH:
1. Backup Database VPS
The first way to backup a VPS is to backup the database on the VPS. Before backup, you must enter the directory of the website you want to backup. In this tutorial, we will back up website data in the var/www/html/wordpress directory. Enter the following command to enter the WordPress directory.
~# cd /var/www/html/wordpress
Next, you can start the database backup process with the following command:
~# mysqldump -u nama_user -p Nama_Database > Nama_Database.sq
From this we will backup the database Name_Database. You can change Name_Database according to the name of the database you want to backup. After entering the above command, you will be asked to enter the database password. To make sure the SQL file has been successfully backed up, you can use this command.
~# ls -a
2. VPS Backup Folder
Next is to backup the website directory. Before doing a backup, make sure you have ZIP installed on your server. If you haven't installed ZIP, use this command to install ZIP on your server.
~# sudo apt-get install zip
Then enter the directory you want to backup In this case we will back up the WordPress directory. Enter the following command to enter the directory to be backed up (Replace wordpress with your directory):
# zip -r wp.zip wordpress/*
Explanation of the above Commandment:
- wp.zip : is the name of the ZIP file
- wordpress : is the directory you want to archive
- /* : is the command to archive what is in the WordPress directory
To ensure a successful backup process, you can check using the following command:
# ls
3. Download Backup File
After all the backup processes have been completed, you can download them using the website address or server IP that you are using. Use this command to download your backup results:
Choose whether you want to use a Domain name or IP server:
http://IP_Server/Nama_File
http://Nama_Domain.com/Nama_File
Example of using server IP:
http://199.33.54.31/wp.zip
Example of using a Domain name:
http://niagahoster.com/wp.zip
After downloading the backup, make sure to delete the backup file on the server. This is to avoid the possibility of the backup results being downloaded by unauthorized people. You can delete the backup file using the following command.
# rm Nama_File
How to Backup VPS Using WinSCP
Unlike the previous method. If you haven't installed WinSCP, you can download it here. Here are the complete steps for VPS backup using WinSCP.
1. Login Server
The first thing you have to do is login the server. For server login, you need to fill in the following details:
- Host Name : Is the IP address of your server
- Post Number : Is the SSH Port of your server
- User Name : Username is the user of your server
- Password : Is your Password server.
Once you've filled everything in, click Login to log into your server.
2. Move User Root to Directory
After successfully logging into the server move the root user to the /<root> directory by clicking /<root> as shown below.
Then many files will appear in the / <root> directory as shown below.
3. Select the Directory to Back Up
- Find your website folder. In this tutorial, the website folder is in /var/www/html/. First find the var folder then www and finally html as in the image below.
- Once you are in the website directory, select the directory you want to back up by right-clicking on the directory and then clicking download.
- There will then be an option for your preferred download location.
- Click OK to continue the download process. Make sure you have a stable internet connection during this download process because a poor internet connection will interfere with the backup file download process and can cause the file to error.