How to Transfer Data via Private Network Using Rsync and SCP
How to Transfer Data via Private Network Using Rsync and SCP
Transferring data securely and efficiently between VPS instances within a VirtFusion private network is essential for maintaining data integrity, privacy, and improving performance. Before you proceed, ensure that you have enabled and properly configured your private network according to this guide.
In this example, we will use the following IP addresses:
- Server A:
10.20.1.1/16
- Server B:
10.20.1.2/16
Ensure your servers can ping each other over the private network before proceeding. Typically, you will SSH into your servers using their public IP addresses first, then use the private network for data transfer.
Method 1: Using Rsync
Rsync provides fast, secure, and incremental data transfers between servers.
Step-by-Step Guide
- Install Rsync (if not already installed)
- On AlmaLinux/CentOS:
yum install rsync -y
- On Ubuntu/Debian:
apt install rsync -y
- Transfer Data
Run the following command on Server A to transfer data to Server B:
rsync -avz /path/to/source/ [email protected]:/path/to/destination/
Replace:
/path/to/source/
with your actual source directory or file path./path/to/destination/
with your desired destination path on Server B.
Example:
rsync -avz /home/user/data/ [email protected]:/home/user/data/
Method 2: Using SCP
SCP securely transfers files between servers using the SSH protocol.
Step-by-Step Guide
- Ensure SCP (OpenSSH Client) is installed
- On AlmaLinux/CentOS:
yum install openssh-clients -y
- On Ubuntu/Debian:
apt install openssh-client -y
- Transfer Data
On Server A, run:
scp -r /path/to/source/ [email protected]:/path/to/destination/
Example:
scp -r /home/user/data/ [email protected]:/home/user/data/
Verifying Data Transfer
Confirm the successful transfer by logging into Server B (via public IP) and checking the transferred data:
ssh root@PUBLIC_IP_SERVER_B
ls -l /home/user/data/
You should see your files and directories listed, confirming the transfer was successful.
Conclusion
By following this guide, you can securely and efficiently transfer data over your VirtFusion private network using Rsync or SCP. Utilizing these methods helps maintain secure internal communications, reduce transfer times, and improve overall network efficiency.