Data recovery after mounting a cloud snapshot on an Elastic Cloud Host Linux system.
Published: 2018-08-15
First refer to mounting snapshotshttps://www.west.cn/faq/list.asp?unid=1215 Generally, only the data disk is mounted; this tutorial uses mounting the data disk as an example.
Note: After copying and restoring the data, you must shut down the server so the system can unmount it, and then power it on again for use.
If you do not shut down to unmount it, when the server automatically unmounts it in the early morning, it will also shut down and restart (which may affect data). In addition, do not modify or store other important data on the mounted disk.
After mounting, log in to the server via SSH. For how to connect remotely, see the instructions: http://faq.myhostadmin.net/faq/listagent.asp?unid=417
Run the following commands to mount the partition (red indicates commands to execute; copy the red part to execute, green indicates notes added in this tutorial).
[root@ebs-37458 ~]# df -lh //Check partition status
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 30G 2.1G 26G 8% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/vdb1 20G 194M 19G 2% /home
Then enter fdisk -l to view disk partitions, as shown in the figure:

Use df -lh to view mounted partitions. You can see that /dev/vda1 corresponds to the / partition, and /dev/vdb1 corresponds to the /home partition. /dev/vdc1 does not have a corresponding mount. /dev/vdc1 is the newly mounted partition, and next you need to mount it.(Note: If both the system disk and data disk are mounted, there will also be a /dev/vdd1)
Mount command:
[root@ebs-37458 ~]# mkdir /home1 //Create the home1 directory; you can also name this directory yourself
[root@ebs-37458 ~]# mount /dev/vdc1 /home1 //Mount the backup partition to the home1 directory
Use the df -lh command to view; you can see that home1 has been mounted to /dev/vdc1. Now /home1 is the backup data. Whatever data you need, copy it from there.

Note: The mounted disk partition is generally /dev/vdc1 by default. When entering the mount command, use the actual partition name you see.
Data copy example
Copy command cp -rf /home1/xxx/* /home/xxx Explanation: Copy files under the /home1/xxx/ directory to /home/xxx
The default website directory structure of our company's wdcp system: /home/wwwroot/site_name/public_html
As shown in the figure, after logging in to wdcp, click the site list to see the specific website path.

Taking the above figure as an example, the website directory path is /home/wwwroot/test_com, and you want to restore this website's files.
Enter the following command:
/bin/cp -rf /home1/wwwroot/test_com/public_html/* /home/wwwroot/test_com/public_html/
chown www.www /home/wwwroot/ -R Explanation: Reset the owner of the wwwroot directory
Default database path /home/wddata/var If you want to restore the database dbsql, the command is:
cp -rf /home1/wddata/var/dbsql/* /home/wddata/var/dbsql/ Explanation: Copy /home1/wddata/var/dbsql/ to /home/wddata/var/dbsql/
Reset directory owner: chown mysql.mysql /home/wddata/var/dbsql/ -R Explanation: Reset the owner of the /home/wddata/dbsql/ directory
In addition, you can connect to the server via sftp to download the backup data inside. Refer to the tutorial: http://faq.myhostadmin.net/faq/listagent.asp?unid=637
Also attached is the method for restoring sites after reinstalling the system: http://faq.myhostadmin.net/faq/listagent.asp?unid=608
Note: After copying and restoring the data, you must shut down the server so the system can unmount it, and then power it on again for use.
If you do not shut down to unmount it, when the server automatically unmounts it in the early morning, it will also shut down and restart (which may affect data). In addition, do not modify or store other important data on the mounted disk.
