File BackuP & Sync...
SAKSHAM TRIVEDI
Security (SOC) Analyst || Microsoft Certified Security Operation Canter Analyst
Introduction
In today's fast-paced world, seamless file sharing and synchronization are essential for efficient collaboration between teams and remote work. However, transferring large files or entire directories can be time-consuming and inefficient, especially when the same files are frequently updated. In this article, we will explore how to use the powerful rsync command in Fedora to transfer files and directories between hosts on the same network while uploading only the changes made to the files. This incremental upload method significantly reduces data transfer and saves valuable time, making it an ideal solution for businesses and individuals seeking a more efficient file sharing process.
Prerequisites
Before we delve into the process, ensure that both the source and destination hosts are connected to the same network. Additionally, rsync should be installed on both machines.
To install rsync type:
$ sudo dnf install rsync
Steps to Accomplish that
Step 1
Set up SSH Key-Based Authentication (Optional but Recommended):
To enhance security and streamline the transfer process, we highly recommend setting up SSH key-based authentication between the source and destination hosts. This will eliminate the need to enter a password each time you initiate a transfer.
On the source machine, generate an SSH key by running the following command in the terminal
$ ssh-keygen
Press Enter to accept the default options for key generation. This will create the SSH keys in the ~/.ssh directory.
Next, copy the public key to the destination machine using the following command
ssh-copy-id user@destination_host_ip
Replace user with the username on the destination machine and destination_host_ip with the 'IP address' or 'hostname' of the destination machine. You'll need to enter the password for the destination machine this time.
领英推荐
Step 2
Performing the Incremental Upload using Rsync
Now that the SSH key-based authentication is set up (if applicable), it's time to initiate the incremental file transfer using rsync.
Open a terminal on the source machine and use the following rsync command
rsync -avz --progress --delete /path/to/source/directory/ user@destination_host_ip:/path/to/destination/directory/
Explanation of the rsync options used:
Replace /path/to/source/directory/ with the path to the directory you want to transfer files from and /path/to/destination/directory/ with the path to the directory where you want to upload the files on the destination machine.
Conclusion
In conclusion, the rsync command provides a powerful and efficient solution for transferring files and directories between hosts connected to the same network. By leveraging the incremental upload feature, rsync only transfers the changes made to files since the last synchronization, significantly reducing data transfer and saving valuable time. This method is particularly beneficial for businesses and individuals seeking streamlined collaboration and remote work processes.
Incorporating rsync into your file sharing workflow can enhance productivity and efficiency, making it a valuable addition to any Linux user's toolkit.
That's It for now feel free to reach out to me or explore more Write-Ups by me.