You should regularly back up files on your local disks to prevent data loss or corruption caused by accidental deletion, modification, or overwrites. This practice improves data security. This topic describes three common methods to back up your files: using Cloud Backup for scheduled backups, backing up to OSS, and backing up to a cloud disk or NAS. This topic does not apply to backing up self-managed databases.
This topic applies only to backing up files on local disks. To back up a database that is stored on your local disk, see Back up a self-managed database on an ECS instance.
Method 1: Use Cloud Backup for scheduled backups
|
Scenarios |
Limitations |
Features |
Costs |
|
Cloud Backup supports scheduled backups of files and folders on ECS instances, such as local disks and self-managed databases like Oracle, MySQL, and SQL Server. You can restore data when needed. This method is suitable for scenarios that require a highly reliable backup solution. For more information about Cloud Backup, see Why choose Cloud Backup?. |
|
|
Includes charges for File Backup software usage and storage capacity. For more information about billing, see ECS file backup costs. |
Procedure
-
Make preparations.
-
Ensure that the region where the local disk resides supports Cloud Backup. For a list of supported regions, see Available regions.
-
Ensure that the Cloud Assistant Agent is installed on the ECS instance where the local disk is located.
ImportantIf you purchased your instance after December 1, 2017, the Cloud Assistant client is pre-installed by default. Otherwise, you must install the Cloud Assistant Agent.
-
-
Log on to the Cloud Backup console and select the region where the local disk is located.
-
In the navigation pane on the left, choose . On the ECS Instances tab, find the instance that contains the local disk. In the Actions column, click Backup.

-
On the Create Backup Plan page, configure the parameters as prompted and click OK.
Take note of the following parameters. Configure all other parameters as needed. For more information, see Back up ECS files:
-
Backup Folder Rule: Select Specified Folders.
-
Source Paths: Enter the absolute paths of the local disk data that you want to back up. You can specify multiple paths. For information about specific rules, refer to the on-screen prompts.
-
Backup Policy: Specifies the backup time, epoch, retention period, and other settings. If you have not created a backup policy, you must first create a backup policy.
When the scheduled backup time is reached, the system starts the backup job. When the backup job Status changes to successful, the backup for the day is complete. You can view the backup point in the backup history.

-
Related operations
-
Restore data: After you back up local disk data to a Cloud Backup vault, you can restore files from a historical backup point if the files are lost or become abnormal. For more information, see Restore ECS files.
-
Browse and download backed up files: For more information, see Back up ECS files.
Method 2: Regularly back up to OSS
You can use the ossutil and crontab commands with an automated script to regularly back up local disk data to OSS.
|
Scenarios |
Features |
Costs |
|
Suitable for large-scale data backups, especially for solutions that require low costs and high reliability. For more information about the features of OSS, see Benefits of OSS. |
Requires scripting. |
Charges for OSS storage fees. For more information about billing, see Storage fees. |
This solution is a simple example that provides a basic approach. It has limitations, and you must adapt it to your business needs.
For example, this solution performs a full backup every time, which consumes an increasing amount of storage space over time. Packaging the entire directory into a single ZIP file can negatively affect backup speed and storage efficiency. In real-world business scenarios, you may need to implement additional policies, such as:
-
Incremental or differential backups: Back up only the data that has changed since the last backup. This method uses storage resources more efficiently and speeds up the backup process.
-
Chunked backups: Divide the dataset into smaller chunks or group them for backup based on directory structure, file type, or other logical criteria.
Procedure
-
Make preparations.
-
Activate OSS and create an OSS bucket. For more information, see Create a bucket.
-
Obtain the OSS bucket name, the OSS endpoint, and the storage path of the local disk data you want to back up.
-
-
Log on to the ECS instance.
-
Install ossutil and configure access credentials.
ImportantThe ECS instance that has the local disk must have Internet access to download ossutil. For more information, see How do I enable Internet access for an ECS instance?
-
Install ossutil.
sudo yum install unzip -y sudo -v ; curl https://gosspublic.alicdn.com/ossutil/install.sh | sudo bash -
Configure access credentials for ossutil.
Create a
.ossutilconfigfile in the user directory and configure the access credentials.sudo -i # Switch to the root user. If the current user does not have sudo permissions, log on or escalate privileges using another method. cat <<EOF > /root/.ossutilconfig [Credentials] language=EN endpoint=YourEndpoint accessKeyID=YourAccessKeyId accessKeySecret=YourAccessKeySecret EOFReplace
YourEndpoint,YourAccessKeyId, andYourAccessKeySecretwith your actual values.
-
-
Implement scheduled backups.
-
Install a compression tool. This example uses
zip.sudo yum install zip -
Write a backup script. For example, `backup_to_oss.sh`.
-
-
Grant execute permissions to the script and test it.
sudo chmod +x /home/backup_to_oss.sh /home/backup_to_oss.shEnsure that the script runs without errors and that the data is successfully uploaded to OSS.
-
Run
crontab -eto open the crontab editor. Add a line to schedule your backup script. For example, to run it at 2:00 AM every day:0 2 * * * /home/backup_to_oss.shReplace
/home/backup_to_oss.shwith the actual path to your script. -
Configure other settings as needed.
-
Download backed up data
You can download backed up data from OSS using the OSS console, the ossutil command line interface, or other methods. For more information, see Simple download.
Method 3: Regularly back up to a disk or NAS on the same instance
You can regularly back up local disk data as a ZIP package to a specified path on a cloud disk or in a File Storage NAS file system.
|
Scenarios |
Features |
Costs |
|
Requires scripting. |
|
This solution is a simple example that provides a basic approach. It has limitations, and you must adapt it to your business needs.
For example, this solution performs a full backup every time, which consumes an increasing amount of storage space over time. Packaging the entire directory into a single ZIP file can negatively affect backup speed and storage efficiency. In real-world business scenarios, you may need to implement additional policies, such as:
-
Incremental or differential backups: Back up only the data that has changed since the last backup. This method uses storage resources more efficiently and speeds up the backup process.
-
Chunked backups: Divide the dataset into smaller chunks or group them for backup based on directory structure, file type, or other logical criteria.
Procedure
-
Make preparations.
-
Create a new cloud disk (data disk) for the instance that has the local disk, and then attach and initialize the cloud disk. Alternatively, you can attach a NAS file system.
For more information, see Create and use a cloud disk or Create a NAS file system and attach it to an ECS instance.
-
Obtain the mount path of the cloud disk or NAS file system and the storage path of the local disk data that you want to back up.
-
-
Set up scheduled backups.
-
Log on to the ECS instance.
-
Install the ZIP tool. The following example uses Alibaba Cloud Linux.
sudo yum install zip -
Write a backup script. For example, `/home/backup_script.sh`.
Run the following command to write and save the script.
vim /home/backup_script.sh -
Save the script and grant execute permissions to the script.
sudo chmod +x /home/backup_script.shReplace
/home/backup_script.shwith the actual path to your script. -
Run
crontab -eto open the crontab editor. Add a line to schedule your backup script. For example, to run it at 2:00 AM every day:0 2 * * * /home/backup_script.shReplace
/home/backup_script.shwith the actual path to your script. -
-
Download backed up data
-
Data backed up to a cloud disk: For more information, see Upload or download files.
-
Data backed up to NAS: For more information, see Migrate NAS data to a local machine.
Related operations
-
Migrate local disk data to another ECS instance
You can use a one-click solution to migrate all data from one or more instances that have local disks to other ECS instances. The data is stored on the cloud disks of the destination instances, which creates a complete backup. For more information, see Migrate a source server to a destination instance.
-
Handle local disk corruption
If a local disk is corrupted, Alibaba Cloud triggers a system event and promptly sends you a notification that contains response measures and event lifecycle information. You can perform O&M operations based on the scenario. For more information, see O&M scenarios and system events for instances with local disks.