Synchronize data between two General-purpose NAS file systems in different zones of the same region using rsync. If the business file system becomes unavailable due to a zone-level outage, switch workloads to the disaster recovery file system.
File Storage NAS stores multiple replicas of data on different devices within the same zone. A zone-level service suspension caused by force majeure factors can temporarily block access to the file system. This cross-zone disaster recovery solution uses rsync for scheduled synchronization, not real-time replication. The recovery point objective (RPO) depends on the synchronization interval configured in the scheduled task.
Infrastructure
| Component | Quantity | Purpose |
|---|---|---|
| VPC | 1 | Interconnects the ECS instance and both NAS file systems |
| vSwitch | 2 (one per zone) | Connects each NAS file system to the VPC; provides network segmentation and isolation |
| General-purpose NAS file system | 2 (different zones, same region) | Business file system + disaster recovery file system |
| ECS instance | 1 | Runs rsync for full and incremental data synchronization |
Example configuration
The following example uses the China (Hong Kong) region.
| Parameter | Business file system | Disaster recovery file system |
|---|---|---|
| Region | China (Hong Kong) | China (Hong Kong) |
| Zone | Hong Kong Zone B | Hong Kong Zone D |
| VPC | test01 | test01 |
| vSwitch | test1 | test2 |
Prerequisites
Before you begin, ensure that you have:
A General-purpose NAS file system (the business file system) that contains the data to protect
A VPC in the target region with vSwitches in at least two zones
An Alibaba Cloud account with permissions to create NAS file systems and ECS instances
Step 1: Create the disaster recovery file system
Create a second General-purpose NAS file system with the same configuration as the business file system, except in a different zone.
Log on to the NAS console.
In the File System Selection Guide section of the Overview page, click Create below General-purpose NAS.
In the Create panel, configure the following parameters. Keep all other parameters the same as the business file system. For more information, see Create a file system.
Parameter Description Region Select the same region as the business file system. In this example, select China (Hong Kong). Zone Select a different zone from the business file system. In this example, select Hong Kong Zone D. VPC Select the same VPC as the business file system. In this example, select test01. vSwitch Select a vSwitch in the target zone. In this example, select test2. Click Buy Now and follow the instructions to complete the payment.
Verify that the new file system appears in the NAS console with a status of Running.
Step 2: Deploy rsync and synchronize data
Mount both file systems on an ECS instance, then use rsync for full synchronization followed by scheduled incremental synchronization. Follow the instructions for your protocol type.
NFS file system
Mount the file systems
Log on to the ECS console. Click Create Instance. On the Custom Launch page, configure the following parameters:
Parameter Value Region Same region as the file systems. In this example, China (Hong Kong). Network and Zone Same VPC as the file systems. Same vSwitch as the file system (recommended). Instance Minimum specification. Image CentOS. In this example, CentOS 7.6. Storage Click Elastic Ephemeral Disk|NAS File System|Dedicated Block Storage Cluster(Optional), then click Add File System to add both the business file system and the disaster recovery file system. 
After the ECS instance is created, verify that both file systems are mounted: The business file system is mounted to
/mnt/srcand the disaster recovery file system is mounted to/mnt/dst.mount | grep nas.aliyuncs.com
Install rsync
sudo yum install -y rsyncPerform a full data synchronization
Create a target directory in the disaster recovery file system:
mkdir /mnt/dst/backupsystemSynchronize all data from the business file system to the disaster recovery file system:
rsync -avP /mnt/src/ /mnt/dst/backupsystem/Verify the synchronization completed without errors by checking the rsync output for a summary line showing the total number of files transferred.
Synchronize incremental data
If applications write data to the business file system during or after the full synchronization, run the following command to synchronize incremental changes:
rsync -avP --delete /mnt/src/ /mnt/dst/backupsystem/rsync scans the entire source directory before synchronizing incremental data. Synchronizing a small amount of data may take longer than expected.
The --delete option removes files from the disaster recovery file system that have been deleted from the business file system. To prevent accidental data loss, enable the recycle bin feature for both file systems. The recycle bin can restore deleted files and their metadata, including user identifiers (UIDs), group identifiers (GIDs), and access control lists (ACLs). For more information, see Recycle bin.
Configure a scheduled task
Use crontab to schedule automatic incremental synchronization.
Open the crontab editor:
crontab -eAdd the following line to run incremental synchronization daily at 00:30: The five fields before the command define the schedule: Adjust the schedule based on your RPO requirements. A more frequent schedule reduces potential data loss but increases resource usage.
Field Value Meaning Minute 30 Run at minute 30 Hour 00 Run at hour 00 (midnight) Day of month * Every day Month * Every month Day of week * Every day of the week 30 00 * * * rsync -avP --delete /mnt/src/ /mnt/dst/backupsystem/ > /tmp/last_rsync_result.log 2>&1 &Verify the scheduled task is saved:
crontab -l
Check the synchronization result
After the scheduled task runs, check the log:
cat /tmp/last_rsync_result.logSMB file system
Mount the file systems
Log on to the ECS console. Click Create Instance. On the Custom Launch page, configure the following parameters:
Parameter Value Region Same region as the file systems. In this example, China (Hong Kong). Network and Zone Same VPC as the file systems. Same vSwitch as the file system (recommended). Instance Minimum specification. Image Windows Server. In this example, Windows Server 2019. Storage Click Elastic Ephemeral Disk|NAS File System|Dedicated Block Storage Cluster(Optional), then click Add File System to add both the business file system and the disaster recovery file system. Public IP Address Select Assign Public IPv4 Address to download the migration tool. 
After the ECS instance is created, verify that both file systems are mounted: Expected output shows the business file system mounted on X drive and the disaster recovery file system mounted on Y drive:
net useStatus Local Remote Network ------------------------------------------------------------------------------- OK Y: \\12e4874****-v****.cn-hongkong.nas.aliyuncs.com\myshare Microsoft Windows Network OK X: \\12f7094****-c****.cn-hongkong.nas.aliyuncs.com\myshare Microsoft Windows Network
Install rsync
Download rsync for windows.
Decompress the downloaded installation package to C drive and rename the folder to cwRsync.
Perform a full data synchronization
Open the Command Prompt and run the following commands. Replace X and Y with the actual drive letters.
cd c:\cwRsync
rsync.exe -avP /cygdrive/X/ /cygdrive/Y/ --no-perms --no-owner --no-groupBy default, SMB file systems do not support account permission configurations. If SMB Active Directory (AD) or ACL is enabled, the --no-perms, --no-owner, and --no-group options are not required.
Synchronize incremental data
Run the following command. Replace X and Y with the actual drive letters.
rsync.exe -avP --delete /cygdrive/X/ /cygdrive/Y/ --no-perms --no-owner --no-group > c:/rsync.logrsync scans the entire source directory before synchronizing incremental data. Synchronizing a small amount of data may take longer than expected.
The --delete option removes files from the disaster recovery file system that have been deleted from the business file system. To prevent accidental data loss, enable the recycle bin feature for both file systems. The recycle bin can restore deleted files and their metadata, including UIDs, GIDs, and ACLs. For more information, see Recycle bin.
Configure a scheduled task
Create a script file named
dailyrsync.baton C drive with the following content. Replace X and Y with the actual drive letters.c:\cwRsync\rsync.exe -avP --delete /cygdrive/X/ /cygdrive/Y/ --no-perms --no-owner --no-group > c:\run.logOpen the Control Panel and click System and Security. In the Administrative Tools section, click Schedule tasks.
In the Task Scheduler window, choose Actions > Create Task.
Click the General tab, enter a task name in Name, and select Run only when user is logged on.
Click the Triggers tab. Click New Trigger. Select On a schedule for Begin the task, select Daily, and specify the execution time. In the Advanced settings section, select Enabled. Click OK.
Click the Actions tab. Click New Action. Select Start a program for Action. In the Program/script section, select the
dailyrsync.batscript file created on C drive. Click OK.Click OK.
Restart the ECS instance and verify that the scheduled task appears in Task Scheduler.

Check the synchronization result
After the scheduled task runs, check rsync.log on C drive to confirm the output of the most recent incremental data synchronization.
Step 3: Perform a switchover
If you need to switch your workloads to the disaster recovery file system, mount the disaster recovery file system on all business systems where the business file system was previously mounted.
NFS file system
Mount the backupsystem directory of the disaster recovery file system to the business system. For more information about mounting, see Scenarios.
sudo mount -t nfs -o vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport <<Mount target>>:/backupsystem <<Business system directory>>Replace the following parameters:
<<Mount target>>-- The mount target of the disaster recovery file system.<<Business system directory>>-- The local directory of the business system to which the disaster recovery file system is mounted. Example:/mnt. The data in this directory reflects the state of the last scheduled synchronization.
SMB file system
Mount the disaster recovery file system to a drive on the business system. For more information about mounting, see Scenarios.
net use Y: \\<<Mount target>>\myshareReplace the following parameters:
<<Mount target>>-- The mount target of the disaster recovery file system.Y-- The drive letter to assign to the disaster recovery file system. The data on this drive reflects the state of the last scheduled synchronization.myshare-- The name of the shared SMB directory. This value cannot be changed.