This topic describes how to upload local data to a Server Message Block (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 Elastic Compute Service (ECS) instance.
    You must configure an 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 and use the ECS instance as an intermediate node. The following table shows the recommended configurations. For more information about how to mount a NAS file system, see Mount NAS file systems 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 IPv4 Address.
      Bandwidth Billing Select Pay-By-Traffic.
      Peak Bandwidth The peak bandwidth. Maximum value: 100 Mbit/s. We recommend that you set this parameter to 100 Mbit/s.
    • You can also mount the NAS file system on an existing ECS instance and use the ECS instance as an intermediate node. For more information, see Mount an SMB file system on Windows.
  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.
  • You are not charged for the inbound traffic of an elastic IP address (EIP). However, you are charged for the outbound traffic of an EIP. Therefore, you are not charged for the traffic that is generated when you upload data to the NAS file system over the Internet. However, you are charged for the traffic that is generated when you download data from the NAS file system. For more information about EIP billing, see Pay-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.
  • You can perform incremental synchronization.
  • 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 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 table shows the recommended configurations. For more information about how to mount a NAS file system, see Mount NAS file systems 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 value: 100 Mbit/s. We recommend that you set this parameter to 100 Mbit/s.
    • You can also mount the NAS file system on an existing ECS instance and use the ECS instance as an intermediate node. For more information, see Mount an SMB file system on a Linux ECS instance.
  2. Install the rsync tool.
    Note You must enable the SSH TCP port 22 for the security group of the associated VPC.
    • Windows

      Download and install the Cygwin simulation environment. During the installation process, you can search for and install rsync. 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 the 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 incremental synchronization mode:
    rsync -avP DirToSync/ root@1.2.3.4:/mnt/DirToSync/
    Replace the parameters in the command with 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 a forward slash /. 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 server 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.
      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: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 and then click +. In the window that appears, select Macintosh HD Directory and press the cmd+ shift+. combination keys to display hidden directories. Then, select the /usr/sbin/cron directory.

      2. Establish a password-free connection between the local server 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: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 amount 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 Implement migration.
Note
  • The migration service is in public preview. If you need to migrate your business data, you can submit a ticket to apply for the whitelist access.
  • 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 self-managed data center 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 data center.

Note You must enable SMB TCP port 445 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 the same way you access your local data. For more information, see Mount an SMB file system on Windows.

You can also deploy business applications on the cloud. Then, you can read and write a large amount 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.