To improve data security and prevent data loss or corruption caused by accidental deletion, modification, or overwriting, you can back up data that is stored on local disks on a regular basis. This topic describes three common backup methods: regular backup by using the Cloud Backup service, backup to Object Storage Service (OSS), and backup to cloud disks or File Storage NAS (NAS).
Method 1: Use Cloud Backup to back up data stored on a local disk on a regular basis
Scenario | Limit | Benefit | Billing |
Cloud Backup provides features such as backup, data encryption, and rapid data restoration. Cloud Backup is suitable for scenarios that require highly reliable backup solutions. For more information about Cloud Backup, see Advantages of Cloud Backup? |
|
| You are charged for file backup software usage and storage capacity. For information about the filling of the Elastic Compute Service (ECS) file backup feature, see the Billing section in the "Overview" topic. |
Procedure
Make preparations.
Make sure that Cloud Backup is supported in the region in which the local disk whose data you want to back up resides. For information about the regions that support Cloud Backup, see Supported regions.
Make sure that Cloud Assistant Agent is installed on the instance equipped with the local disk.
ImportantIf the instance was purchased after December 1, 2017, Cloud Assistant Agent is provisioned on the instance. If Cloud Assistant Agent is not installed, you must install Cloud Assistant Agent on the instance. For more information, see Install Cloud Assistant Agent.
Log on to the Cloud Backup console and select the region in which the local disk resides.
In the left-side navigation pane, choose
. On the ECS Instances tab, find the instance equipped with the local disk and click Back Up in the Actions column.On the Create Backup Plan panel, configure parameters as prompted and click OK.
Take note of the following configurations. For information about other parameters, see the Create a backup plan to periodically back up ECS files section in the "Back up files from an ECS instance" topic.
Backup Folder Rule: Select Specified Folders.
Source Paths: Enter the absolute data storage path of the local disk whose data you want to back up. You can enter multiple paths. For information about the rules, see the prompts.
Backup Policy: Select a backup policy that specifies parameters such as the backup time, backup cycle, and backup retention period. If no backup policy appears, create a backup policy first. For more information, see the Create a backup policy section in the "Manage backup policies" topic.
When the backup time in the backup policy is reached, the system runs the backup job. If the Status of the backup job is Completed, the backup job is completed on the current day. You can view the historical backup points in the backup history.
Related operations
Restore data. After you back up data from a local disk to a cloud backup vault, you can restore files by using historical backup points if the files are missing or corrupted. For more information, see Restore files to an ECS instance.
Browse and download backup files. For more information, see the Browse and download backup files section in the "Back up files from an ECS instance" topic.
Method 2: Back up data from a local disk to OSS on a regular basis
You can run the ossutil
and crontab
commands and compile an automated script to back up data from a local disk to OSS on a regular basis.
Scenario | Requirement | Billing |
This method is suitable for large-scale data backup scenarios, ideal for storage solutions that require low cost and high reliability. For more information about OSS, see Benefits. | Scripts must be compiled. | You are charged OSS storage fees. For more information, see Storage fees. |
This method provides a simple example on how to back up data from a local disk to OSS. You can optimize the example to meet your business requirements.
For example, full backup is performed each time, which causes incremental increases in storage space usage over time, or entire directories are packaged in ZIP files, which reduces backup speed and storage efficiency. In real business scenarios, you can use custom backup policies based on your business requirements. Examples:
Incremental or differential backups: Back up only the modified data since the previous backup to improve storage efficiency and accelerate the backup process.
Block backup: Before you back up data, you can divide the data set into multiple blocks or group the data based on logic such as the directory structure and file type.
Procedure
Make preparations.
Activate OSS and create an OSS bucket. For more information, see Create a bucket.
Obtain the OSS bucket name, OSS endpoint, and data storage path of the local disk whose data you want to back up.
Log on to the ECS instance.
Install the ossutil tool and configure the access credentials.
ImportantTo download the ossutil tool, make sure that the ECS instance equipped with the local disk has access to the Internet. For more information, see Enable public bandwidth for an ECS instance.
Install ossutil.
sudo yum install unzip -y sudo -v ; curl https://gosspublic.alicdn.com/ossutil/install.sh | sudo bash
Configure the access credentials of ossutil.
Create a
.ossutilconfig
file in the user directory and configure the credentials.sudo -i # Switch to the root user. If the current user does not have sudo permissions, use other logon methods or grant the permissions. cat <<EOF > /root/.ossutilconfig [Credentials] language=EN endpoint=YourEndpoint accessKeyID=YourAccessKeyId accessKeySecret=YourAccessKeySecret EOF
Replace
YourEndpoint
,YourAccessKeyId
, andYourAccessKeySecret
with the actual values based on your business requirements.
Implement scheduled backup.
Install the compression tool. In this example, the
zip
tool is installed.sudo yum install zip
Compile the backup script. In this example, the script is named backup_to_oss.sh.
Grant the permissions to run the script and test the script.
sudo chmod +x /home/backup_to_oss.sh ./backup_to_oss.sh
Make sure that the script runs as expected and the data can be uploaded to OSS.
Run the
crontab -e
command to open the crontab editor and add a line to schedule your backup script. For example, run the following command to run the backup script at 02:00 every day:0 2 * * * /home/backup_to_oss.sh
/home/backup_to_oss.sh
: Replace the value with the actual storage path of the script.You can configure other settings as needed.
Download backup data
You can download data that is backed up from OSS in the OSS console or by using ossutil. For more information, see Simple download.
Method 3: Back up data from a local disk to a cloud disk or NAS file system attached to the same instance on a regular basis
Periodically compress local disk data into a ZIP package and back up the data to a specific path of the cloud disk or NAS file system.
Scenario | Requirement | Billing |
| Scripts must be compiled. |
|
This method provides a simple example on how to back up data from a local disk to OSS. You can optimize the example to meet your business requirements.
For example, full backup is performed each time, which causes incremental increases in storage space usage over time, or entire directories are packaged in ZIP files, which reduces backup speed and storage efficiency. In real business scenarios, you can use custom backup policies based on your business requirements. Examples:
Incremental or differential backups: Back up only the modified data since the previous backup to improve storage efficiency and accelerate the backup process.
Block backup: Before you back up data, you can divide the data set into multiple blocks or group the data based on logic such as the directory structure and file type.
Procedure
Make preparations.
Create a data disk for the instance equipped with the local disk, and attach and initialize the data disk. Alternatively, mount a NAS file system to the instance.
For more information, see Quickly create and use a cloud disk or Step 2: Mount the file system in the NAS console of the "Mount a file system on a Linux ECS instance" topic.
Obtain the mount path of the cloud disk or NAS file system, and the data storage path of the local disk whose data you want to back up.
Configure scheduled backup.
Log on to the ECS instance.
Install the ZIP tool. In the following example, Alibaba Cloud Linux is used.
sudo yum install zip
Compile the backup script. In this example, the script is stored in the /home/backup_script.sh directory.
Run the following command to compile and save the script:
vim /home/backup_script.sh
Save the script and grant the permissions to run the script.
sudo chmod +x /home/backup_script.sh
/home/backup_script.sh
: Replace the value with the actual storage path of the script.Run the
crontab -e
command to open the crontab editor and add a line to schedule your backup script. For example, run the following command at 02:00 every day:0 2 * * * /home/backup_script.sh
/home/backup_script.sh
: Replace the value with the actual storage path of the script.
Download backup data
Backup to a cloud disk: For more information, see Upload a file from on-premises to an ECS instance.
Backup to a NAS file system: For more information, see Migrate data from a NAS file system to an on-premises storage system.
Related operations
Migrate data from a local disk to another ECS instance
You can migrate all data of one or more instances with local disks to another ECS instance with a few clicks, and store the data in the cloud disks attached to the destination instance. This way, the data of the source instances with local disks is backed up. For more information, see Migrate servers to ECS instances.
Handle local disk damages
If a local disk is damaged, Alibaba Cloud triggers a system event and sends notifications, countermeasures, and event cycles. You can perform O&M based on scenarios. For more information, see O&M scenarios and system events for instances equipped with local disks.