All Products
Search
Document Center

File Storage NAS:Configure a disaster recovery solution for a General-purpose NAS file system

Last Updated:Dec 13, 2024

This topic describes how to configure a disaster recovery solution for a General-purpose File Storage NAS (NAS) file system across zones in the same region by using the rsync command-line tool.

Overview

NAS stores multiple replicas of data on different devices in the same zone. To prevent an application from being unable to access data in a short period of time due to service suspension caused by force majeure factors, you can use the rsync command-line tool to configure a disaster recovery solution for your General-purpose NAS file system across zones in the same region.

In this solution, you must deploy the following infrastructure and cloud services:

  • A virtual private cloud (VPC). The VPC serves as a private network that interconnects your Elastic Compute Service (ECS) instance and NAS file systems on the cloud.

  • Two vSwitches. The vSwitches connect the two NAS file systems to the same network and provides basic network segmentation and isolation.

  • Two NAS file systems. The two NAS file systems reside in different zones of the same region and provide storage services with high performance and high availability. If the business file system fails, your workloads can be switched to the disaster recovery file system. This ensures business continuity and stability.

  • An ECS instance. You can use the rsync command-line tool to migrate data, and configure a scheduled task to migrate incremental data. This way, data can be shared and synchronized between the two NAS file systems and data consistency is ensured.

Solution

This topic describes how to build disaster recovery capabilities for a General-purpose NAS file system that resides in Hong Kong Zone B of the China (Hong Kong) region. The following table describes the required parameters.

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

Step 1: Create a file system

Create a disaster recovery file system that has the same configurations as the business file system except for the zone.

  1. Log on to the NAS console.

  2. In the File System Selection Guide section of the Overview page, click Create below General-purpose NAS.

  3. In the Create panel, configure the following parameters. Keep the settings of the other parameters the same as those of the business file system. For more information, see Create a file system.

    Parameter

    Description

    Region

    Select the region where the business file system resides. In this example, select China (Hong Kong).

    Zone

    Select a zone that is different from the zone where the business file system resides. In this example, select Hong Kong Zone D.

    VPC

    Select the VPC where the business file system resides. In this example, select test01.

    vSwitch

    Select a vSwitch that resides in the VPC. In this example, select test2.

  4. Click Buy Now and follow the instructions to complete the payment.

Step 2: Deploy a data migration system and migrate data

After you create the disaster recovery file system, you must mount the two NAS file systems on your ECS instance. Then, use the rsync command-line tool to migrate data, and configure a scheduled task to migrate incremental data. Perform the following steps to migrate data:

NFS file system

  1. Mount the business file system and the disaster recovery file system.

    Log on to the ECS console. Click Create Instance. On the Custom Launch page, configure the following parameters:

    • Region: Select the region where the file system resides. In this example, select China (Hong Kong).

    • Network and Zone: You must select the same VPC as the file system. We recommend that you select the same vSwitch as the file system.

    • Instance: Select the minimum specification.

    • Image: Select CentOS. In this example, select CentOS 7.6.

    • Storage: Click NAS File System(Optional) and click Add File System to add two shared disks for the business file system and the disaster recovery file system. The following figure shows the details.

      image.png

      After you create the ECS instance and mount the business file system and the disaster recovery file system, run the following command to verify the mount:

      mount | grep nas.aliyuncs.com

      If an output that is similar to the following information appears, the file systems are mounted. The business file system is mounted to the /mnt/src directory, and the disaster recovery file system is mounted to the /mnt/dst directory.

      image.png

  2. Install the migration tool.

    sudo yum install -y rsync
  3. Migrate the existing data.

    1. Create a directory in the disaster recovery file system. Example: dst/backupsystem.

      mkdir /mnt/dst/backupsystem
    2. Migrate data from the business file system to the backupsystem directory of the disaster recovery file system.

      rsync -avP /mnt/src/ /mnt/dst/backupsystem/
  4. Migrate incremental data.

    If an application that runs on another ECS instance writes data to the business file system during data migration, you must migrate the incremental data to the disaster recovery file system after the existing data is migrated.

    rsync -avP --delete /mnt/src/ /mnt/dst/backupsystem/

    The rsync command scans the source directory before the command synchronizes incremental data. Therefore, the time required to migrate a small amount of data may be longer than expected.

    Warning

    The --delete option in the command is used to delete data that has been deleted from the business file system from the disaster recovery file system during incremental data synchronization. To prevent accidental deletion of data from the disaster recovery file system, proceed with caution when you use this option. You can also enable the recycle bin feature for the two file systems. If you accidentally delete files from the business file system or the disaster recovery file system, you can use the recycle bin feature to restore these files and their metadata such as user identifiers (UIDs), group identifiers (GIDs), and access control lists (ACLs). For more information, see Recycle bin.

  5. Configure a scheduled task to migrate incremental data.

    Use crontab to configure a scheduled task to migrate incremental data.

    1. Run the following command to go to crontab:

      crontab -e
    2. Configure a scheduled task to migrate incremental data.

      Configure the following information in crontab. 30 indicates minutes and 00 indicates hours. The task is run at 00:30:30 every day to migrate incremental data. You can also specify the values based on your business requirements.

      30 00 * * * rsync -avP --delete /mnt/src/ /mnt/dst/backupsystem/ > /tmp/last_rsync_result.log 2>&1 &
    3. Run the following command to check that the configuration is successful:

      crontab -l
  6. Check the migration result.

    Run the following command to confirm the output of the most recent incremental data synchronization:

    cat /tmp/last_rsync_result.log

SMB file system

  1. Mount the business file system and the disaster recovery file system.

    Log on to the ECS console. Click Create Instance. On the Custom Launch page, configure the following parameters:

    • Region: Select the region where the file system resides. In this example, select China (Hong Kong).

    • Network and Zone: You must select the same VPC as the file system. We recommend that you select the same vSwitch as the file system.

    • Instance: Select the minimum specification.

    • Image: Select Windows Server. In this example, select Windows Server 2019.

    • Storage: Click NAS File System(Optional) and click Add File System to add two shared disks for the business file system and the disaster recovery file system. The following figure shows the details.

      image.png

    • Public IP Address: Select Assign Public IPv4 Address to download the migration tool.

    After you create the ECS instance and mount the business file system and the disaster recovery file system, run the following command to verify the mount:

    net use

    If an output that is similar to the following information appears, the file systems are mounted. The business file system is mounted on X drive, and the disaster recovery file system is mounted on Y drive.

    Status       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
  2. Install the migration tool.

    1. Download the migration tool rsync for windows.

    2. Decompress the downloaded installation package to C drive and change the package name to cwRsync.

  3. Migrate the existing data.

    Open the Command Prompt and run the following commands to migrate data from the business file system to the disaster recovery file system:

    cd c:\cwRsync
    rsync.exe -avP /cygdrive/X/ /cygdrive/Y/ --no-perms --no-owner --no-group

    Replace X and Y in the commands with the actual drive letters.

    Note

    By default, SMB file systems do not support account permission configurations. If SMB Active Directory (AD) or ACL is enabled, you do not need to configure the --no-perms, --no-owner, and --no-group options.

  4. Migrate incremental data.

    rsync.exe -avP --delete /cygdrive/X/ /cygdrive/Y/ --no-perms --no-owner --no-group > c:/rsync.log

    The rsync command scans the source directory before the command synchronizes incremental data. Therefore, the time required to migrate a small amount of data may be longer than expected.

    Warning

    The --delete option in the command is used to delete data that has been deleted from the business file system from the disaster recovery file system during incremental data synchronization. To prevent accidental deletion of data from the disaster recovery file system, proceed with caution when you use this option. You can also enable the recycle bin feature for the two file systems. If you accidentally delete files from the business file system or the disaster recovery file system, you can use the recycle bin feature to restore these files and their metadata such as UIDs, GIDs, and ACLs. For more information, see Recycle bin.

  5. Configure a scheduled task to migrate incremental data.

    1. Create a script file.

      Create a dailyrsync.bat file on C drive and add the following content to the configuration file. Replace X and Y in the commands with the actual drive letters.

      c:\cwRsync\rsync.exe -avP --delete /cygdrive/X/ /cygdrive/Y/ --no-perms --no-owner --no-group  > c:\run.log
    2. Configure a scheduled task to migrate incremental data.

      1. Open the Control Panel and click System and Security. In the Administrative Tools section, click Schedule tasks.

      2. In the Task Scheduler window, choose Actions > Create Task.

      3. Click the General tab, enter a task name in Name, and select Run only when user is logged on.

      4. 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.

      5. Click the Actions tab. Click New Action. Select Start a program for Action. In the Program/script section, select the dailyrsync.bat script file created on C drive in Configure a scheduled task to migrate incremental data. Click OK.

      6. Click OK.

      7. Restart the ECS instance to check whether the scheduled task is created.

        If an output that is similar to the following example appears, the scheduled task is created.

        image.png

        After the task is run successfully, check rsync.log in the C drive to confirm the output of the most recent incremental data synchronization.

Step 3: Perform a switchover

If you need to switch your business to the disaster recovery file system, mount the disaster recovery file system in all the business systems where the business file system is mounted.

NFS file system

This section demonstrates how to mount a disaster recovery NFS file system on Linux. For more information about how to mount a NAS file system, see Scenarios.

Run the following command to mount the backupsystem directory of the disaster recovery file system to the business system:

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>>

The following list describes the parameters. Replace the parameter values based on your business requirements.

  • <<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 to be mounted. Example: /mnt. After the disaster recovery file system is mounted, the data (including directories and files) in this directory is the incremental data migrated by the scheduled task run last time.

SMB file system

This section demonstrates how to mount a disaster recovery SMB file system on Windows. For more information about how to mount a NAS file system, see Scenarios.

net use Y: \\<<Mount target>>\myshare

The following list describes the parameters. Replace the parameter values based on your business requirements.

  • <<Mount target>>: the mount target of the disaster recovery file system.

  • Y: the drive letter of the drive on which the disaster recovery file system is mounted. After the disaster recovery file system is mounted, the data (including directories and files) on the drive is the incremental data migrated by the scheduled task run last time.

  • myshare: the name of the shared SMB directory. You cannot change the name.

Summary

After you read this topic, you have learned about how to:

  • Configure a scheduled task to migrate incremental data

  • Switch your business from the business file system to the disaster recovery file system