Transferring Data from Virtual Disk Storage (VDS) Across Projects

Classification: Storage
Label: VDS

Virtual Disk Service (VDS) is used together with Virtual Compute Service (VCS) to provide additional storage space for VCS instances.

Usage Scenarios

In the past, we have received user feedback requesting the ability to transfer data from virtual disks within one project to another project, which may be necessary when a project expires and data needs to be migrated to a new project, or due to specific usage requirements.

Currently, TWCC does not provide a built-in function for migrating virtual disks. Therefore, we recommend using SCP to transfer data. Below, we introduce the operation method and important considerations.

Application scenario design

Transfer the file test.txt (located in the exptestscp1 folder and already mounted on a virtual disk) from the source host (vmscp1) to the target host (vmscp2) under the exptestscp2 folder (also mounted on a virtual disk).

Experiment Specifications

Both use VCS provided by TWCC with the following specifications:

Source Host
  • Instance Name: vmscp1
  • Project ID: ENT110209
  • Specification: 2 CPU, 16G Memory, 100G System Disk, 10G Data Disk (HDD)
  • OS: (public) Ubuntu 20.04
Target Host
  • Instance Name: vmscp1
  • Project ID: ENT110209
  • Specification: 2 CPU, 16G Memory, 100G System Disk, 10G Data Disk (HDD)
  • OS: (public) Ubuntu 20.04

Detailed Steps

Create and Backup Keys
Backup Keys

To ensure both VCS hosts can transfer files via SCP, we first create an additional key pair. Start on the source host to create and back up the keys.

cd ~/.ssh
cp authorized_keys backup.txt
vi backup.txt
cd

Backup the data in authorized_keys to another file for later use.
It is important to ensure backups are correctly created. After file transfer, you must restore the original key to reconnect to the instance. Without this, the original VCS will not be accessible.
Create Keys

On the source host (vmscp1), use ssh-keygen to create the SCP transfer key.

ssh-keygen

Generate the public/private key pair..
The public key is stored in id_rsa.pub. Its contents will be key to connecting the two VCS instances in the next steps.
You can press Enter to skip passphrase prompts.

cd ~/.ssh
cp id_rsa.pub authorized_keys
cat authorized_keys

Copy the content of id_rsa.pub into authorized_keys as a prerequisite for SCP transfer.
Copy the content of id_rsa.pub; it will be pasted into the target host later.

On the target host (vmscp2), back up the contents of authorized_keys:

cd ~/.ssh
cp authorized_keys backup.txt
vi backup.txt

Same as the source host: back up authorized_keys and check backup.txt.
The contents of backup.txt, which will be restored later after SCP transfer.

Replace authorized_keys on the target host (vmscp2) with the contents copied from the source host (vmscp1).

Synchronize authorized_keys between source and target hosts to allow direct SCP transfer.

After pasting, press Esc, then type :wq and hit Enter to save.

Use SSH to test connectivity:

ssh @

The red box shows the SSH command. The username part of the TWCC VCS is usually ubuntu, and the IP is the public IP. A change in username prompt indicates successful login.
File transfer

Use the SCP command to transfer files:

scp // @:/path/

The red box shows an SCP command example. A progress bar at 100% confirms successful file transfer. .

To verify, log into the target host and check the target folder for the file:

File successfully transferred to the target host (vmscp2).
Restore Keys

On both the source host (vmscp1) and target host (vmscp2), restore the original keys:

cd ~/.ssh
cp backup.txt authorized_keys

Restore authorized_keys with backup.txt to ensure normal login using the original key.
Restore authorized_keys with backup.txt to ensure normal login using the original key.

Notes

1. When backing up VDS using SCP, always keep the original key.

2. After modifying the key, ensure the VCS does not disconnect; otherwise, you may lose access to the instance.

Image source: pexels

EDM Subscription

EDM Subscription

On-Demand AI Cloud Consulting

Sales Contact
Sales Contact Form