This topic describes how to upload local data to an SMB file system over the Internet and download data from an SMB file system to a local server.

Prerequisites

Solution 1: IIS FTP

If you need to upload and download a small number of files, we recommend that you install and configure an FTP client in your local server. This solution has the following benefits:
  • Supports multiple operating systems.
  • Provides a graphical user interface (GUI).
  1. Configure an ECS instance.
    To access Apsara File Storage NAS over the Internet, you must configure an ECS instance as an intermediate node.
    Note Uploading data to or downloading data from a NAS file system consumes the Internet bandwidth of an ECS instance. We recommend that you purchase a new ECS instance and use it to upload and download data.
    • We recommend that you use a newly purchased ECS instance to mount a NAS file system as an intermediate node. The following figure shows the recommended configurations. For more information about how to mount a NAS file system, see Mount a NAS file system when you purchase an ECS instance.
      Table 1. Basic configurations
      Parameter Description
      Image We recommend that you select Windows 2019.
      Table 2. Networking
      Parameter Description
      Public IP address Select Assign Public IP Address.
      Bandwidth Billing Select Pay-By-Traffic.
      Peak Bandwidth The peak bandwidth. Maximum: 100 Mbit/s. We recommend that you set this parameter to 100 Mbit/s.
    • Select an existing ECS as the intermediate node to mount the NAS file system. For more information.
  2. Configure the IIS FTP service on the ECS instance and configure the FTP client in the local server. For more information, see Set up the Windows IIS Web service.
Note
  • You must enable the FTP TCP port for the security group of the associated VPC.
  • You can also configure other FTP servers and clients to upload and download data over the Internet.
  • Inbound traffic of an elastic IP address (EIP) does not incur fees, but outbound traffic of an EIP does. Therefore, uploading data to the NAS file system over the Internet does not incur traffic fees, but downloading data from the NAS file system does. For more information about billing details, seePay-as-you-go .

Solution 2: rsync

If you need to frequently upload and download a large number of files, we recommend that you install the rsync command-line tool on your local server. This solution has the following benefits:
  • After a file is uploaded or downloaded, the metadata of the file remains unchanged, including the owner and permission information.
  • Incremental data synchronization is supported.
  • You can configure crontab for your local Linux or macOS system to automatically back up data to the NAS file system.
  1. Configure an ECS instance.
    You must configure an Elastic Compute Service (ECS) instance as an intermediate node to access Apsara File Storage NAS from the Internet.
    Note Uploading data to or downloading data from a NAS file system consumes the Internet bandwidth of an ECS instance. We recommend that you purchase a new ECS instance and use it to upload and download data.
    • We recommend that you use a newly purchased ECS instance to mount the NAS file system as an intermediate node. The following figure shows the recommended configurations. For more information about how to mount a NAS file system, see Mount a NAS file system when you purchase an ECS instance.
      Table 3. Basic configurations
      Parameter Description
      Image We recommend that you select CentOS 8.0 64-bit.
      Table 4. Networking
      Parameter Description
      Public IP address Select Assign Public IP Address.
      Bandwidth Billing Select Pay-By-Traffic.
      Peak Bandwidth The peak bandwidth. Maximum: 100 Mbit/s. We recommend that you set this parameter to 100 Mbit/s.
    • Use an existing ECS instance to mount NAS as the intermediate node. For more information, seeMount an SMB file system on a Linux ECS instance.
  2. Install the rsync tool.
    Note You must enable the SSH (TCP 22) port for the security group of the associated VPC.
    • Windows

      Download and install Cygwin simulation environment, you can search for and install rsync during the installation process. You can also download, compile, and install rsync.

    • Linux
      • If you are using a CentOS or Red Hat operating system, run the following command to install rsync by using the yum package manager:
        sudo yum install rsync
      • If you are using an Ubuntu or Debian operating system, run the following command to install rsync by using the apt package manager:
        sudo apt-get install rsync
      • If you are using a different version of Linux, use the corresponding package manager to install rsync.
    • macOS
      Download and install homebrew package manager, and then run the following command to install rsync:
      brew install rsync
  3. Upload data.
    Run the following command to upload a specified local directory to the NAS file system in the incremental synchronization mode:
    rsync -avP DirToSync/ root@1.2.3.4:/mnt/DirToSync/
    Modify the parameters in the command based on the actual values. The following table describes the parameters.
    Parameter Description
    DirToSync The name of the local directory that you want to upload.
    root The owner of the destination directory in the NAS file system.
    1.2.3.4 The public IP address of a Linux ECS instance on which an SMB file system is mounted.
    /mnt A path in the ECS instance. The path is used to mount the NAS file system.
    Note The source path in the rsync command must end with /. Otherwise, the source path does not match the destination path after the data is synchronized.
  4. Download data.
    Run the following command to download data from the NAS file system to a local directory:
    rsync -avP root@1.2.3.4:/mnt/DirToSync/ DirToSync/
  5. Configure automatic upload.
    You can configure crontab for your local Linux or macOS system to upload data at a regular interval by running rsync commands.
    • For Linux operating systems:
      1. Establish a password-free connection between the local system and the ECS instance. For more information, seeConnect to a Linux instance by using an SSH key pair .
        Run the following command to check whether the connection is successful:
        ssh -i ~/.ssh/ecs.pem root@1.2.3.4
        Note ~/.ssh/ecs.pem is the path of the key file on your local server.
      2. Configure crontab.
        Run the crontab -e command to open the editor and configure a scheduled time to upload tasks. The following example shows the sample settings:
        0 23 * * * rsync -av -e "ssh -i ~/.ssh/ecs.pem" ~/Documents/ root@1.2.3.4:/mnt/Documents/
        The preceding crontab configuration allows Linux operating systems to automatically upload data from the local Documents directory to the NAS file system at 23:00 every day. You can modify the parameters in the crontab configuration based on your business requirements.
    • For macOS:
      1. Configure access permissions on the /usr/sbin/cron directory.

        Go to System Preferences. In the window that appears, choose Security & Privacy > Privacy > Full Disk Access, click Unlock click +. In the window that appears, select Macintosh HD Directory, press cmd+ shift+. to show the hidden directories, and then select /usr/sbin/cron.

      2. Establish a password-free connection between the local system and the ECS instance. For more information, see Connect to a Linux instance by using an SSH key pair.
        Run the following command to check whether the connection is successful:
        ssh -i ~/.ssh/ecs.pem root@1.2.3.4
        Note ~/.ssh/ecs.pem is the path of the key file on your local server.
      3. Configure crontab.
        Run the crontab -e command to open the editor and configure a scheduled time to upload tasks. The following example shows the sample settings:
        0 23 * * * rsync -av -e "ssh -i ~/.ssh/ecs.pem" ~/Documents/ root@1.2.3.4:/mnt/Documents/
        The preceding crontab configuration allows Linux operating systems to automatically upload data from the local Documents directory to the NAS file system at 23:00 every day. You can modify the parameters in the crontab configuration based on your business requirements.

Solution 3: Upload data to OSS, and then migrate the data to NAS

If you need to upload a large volume of data to the NAS file system, you can upload the data to OSS and then migrate the data from OSS to NAS. We recommend that you use this solution if the Internet bandwidth of the ECS instance cannot meet your requirements. For more information, see Upload objects and Migrate data from OSS to NAS .
Note
  • The migration service is in the public preview process. If you need to migrate your business data, you can to apply for a whitelist.
  • After you migrate your business data, the metadata may be modified. However, you can run rsync commands to restore the metadata.

Solution 4: Mount the NAS file system to an on-premises database

If your on-premises database frequently reads and writes a large volume of data to and from the NAS file system, you must create a physical connection and mount the NAS file system to the database.

Note You must enable the SMB (TCP 445) port for the security group of the associated VPC.

Access uploaded data

After the data is uploaded, you can mount the NAS file system on the ECS instance or the container to which your business belongs. This allows you to share the data in the NAS file system.

For example, you can mount an SMB file system on a Windows ECS instance and access data on the NAS file system in the same way you access your local data. For more information.

You can also deploy business applications on the cloud. Then you can read and write a large volume of data to and from the NAS file system by using programs on multiple compute nodes. For example, you can Use Windows IIS to access Apsara File Storage NAS.