Wondershare UBackit

File Backup

  • Backup files, partitions, NAS disks, hard drives, effectively, incrementally and automatically.
  • Provides many features, such as, disk clone, Outlook backup, scheduled auto backup, and more.
  • Supports 1000+ file formats backup, including JPEG, PNG, AVI, M4V, MOV, MP4, DOC, XLS, PST, etc.
Free Download Free Download Learn More >
data backup

How to Sync Files between Two Linux Server?

Wondershare Recoverit Authors

Nov 16, 2024 • Filed to: Recover Files • Proven solutions

“I am using Linux and want to sync files between two linux servers. But, I have no idea how I can sync files between Linux servers and Windows as well.”

Linux is an open-source operating system similar to Microsoft Windows, Apple Mac OS, Google android, etc. It is based on UNIX and can manages computer software as well as hardware. Now, most organizations are appealing in open source expertise to attain their Linux environment.

The ability to incorporate open systems with traditional cloud IT infrastructure has a strong effect on dynamic innovation. This operating system appeals to programmers because of its power, versatility, speed, and the package manager that allows them to install software seamlessly.

Linux server for file sync

If you want to learn more about Linux servers, then you are in the right place. Here we will discuss the purpose and different ways to sync files between Linux servers.

Let’s get started!

The Purposes of Syncing Files Between Two Linux Server?

When you want to synchronize a large number of files at different times, you need an efficient service to smoothly run the process. Linux is a real-time file sync service that allows you to sync files easily.

Moreover, when you make any changes to the folder, it will automatically replicate all the changes to your content. Even multiple people can act on the same content simultaneously.

The best part is that you can access all the files on a Linux server from your local desktop or from another device. It offers you an easy and quick one-time set up to share your files between various machines.


How to Sync Files Between Two Linux Computer?

Do want to sync files between sync files between Linux servers or two Linux computers? If yes, then read through this guide.

Linux servers use configuration files to preserve the settings for the services and to attain the expected outcome. Also, note that both servers should have the same up-to-date configurations to start the synchronization process between two Linux computers.

The steps given below will assist you in accomplishing some basic scripting in a CentOS 7 environment.

Step 1- Establish Trust between Both Servers Via SSH

Here you have to start with active/passive configuration, and only administrative changes can take place on the active server.

Then scripts pass this change and start service again on the passive server for sync.

Now, you have to generate an SSH key between both servers in order to validate changes. This is consummate through “ssh-keygen -t dsa.”

Active/passive cluster in Linux

Perform this process on both the servers and then copy the keys that you have created to /root/.ssh/authorized_keys on each server.

Then, check SSH using the new keys, and you ought to be in business.

Step 2- Create Script to Sync Files and Restart a Service

Now you have to create a new directory known as scripts to0 sync files in linux servers. Then make a new script file-haproxySync.sh. In case your statement is wrong or copied, a reverberation indicates the same.

Create new script file-haproxySync.sh

Step 3- Create a New Service to Monitor the Transforms and Execute the Script

Now you need to have something in order to monitor the active server configuration for changes. When you are able to detect the changes, then synchronize the scripts against the passive server.

Sync script against passive server in Linux

Then navigate to /etc/system/system/ on the active server and make two files here that are

The service files inform the service to implement the script. On the other side, the path file notifies the service about the path which needs to monitor.

Now, using the command “systemctl restart monitorFileChange,” begin the service on the active host. Then start the systemctl status monitorFileChange.path to make sure that it runs in the right manner.

But in case it not works properly, then you may also need to troubleshoot and correct it accordingly.

Step 4- Test For Success

Now to test the solution, makes a change to a file inside the /etc/haproxy/ directory from the active server. Simultaneously on the passive server, you can check whether the same changes are reflected there or not.


How Do I Sync Files Between Linux And Windows?

Do you want to copy your important data or files from Linux to a Windows PC or vice versa? If yes, then we have listed three best methods that can help you to solve your problem.

Let’s check out the one by one:

Method 1- With FTP

It is a mouse-driven user interface and easy to use as compare to the type commands. It is important here to note that the SSH server must run on the Linux machine before you start the file transfer process.

FTP for file transfer between windows and linux

Also, make sure that you have an FTP application like FileZilla, which supports “SFTP.” Now follow the given below steps:

Step 1- First of all, you have to navigate and open the File, then go to “Site Manager.”

Step 2- Now, make a site by selecting the “New Site” option.

Step 3- Then, set the Protocol to SSH File Transfer Protocol (SFTP).

Step 4- Now, you have to add the Hostname to the target IP address of the Linux machine.

Target IP address of the Linux machine

Step 5- Then set the Logon and enter “Normal.” Further, enter your username and password and click on the option of “connect.”

Method 2- Create and Mount a VirtualBox Shared Folder in Linux

VirtualBox is already set up for sharing files when you run Windows in a VM on Linux. You must install the “Guest Additions” on your virtual machine before proceeding with further steps.

sync-files-between-two-linux-server-7

Step 1- In the virtual manager, firstly select the VM and click on “Start” and from there, go to “Headless Start.”

In virtualbox manager go to headless start

Step 2- When you see the status that shows the machine is running, right-click on the VM. Then select the settings option and from here go to “Shared Folders.”

Step 3- Now select machine folders from here and browse the Folder Path. Then look for the directory which you want to use and press OK.

You can also use the “Auto-mount” option if you want to show yourself available whenever you runs this tool. Click on “OK” to confirm it.

Method 3- With Shared Network Folders

This is one of the easiest ways among others. In this method, you can share any folder from Windows to be visible on the Linux device. Follow the steps to learn the process:

Step 1- First of all, you have to right-click on the network connections icon from Windows.

Click on the network icon in Windows

Step 2- From here, you have to select the “Open Network & Internet Settings.”

Open network and internet settings

Step 3- Then go to the “Sharing Options.”

Locate sharing option for linux file sync

Step 4- Then, from the current network profile, select “Turn on network discovery” and “Turn on file and printer sharing.”

Turn on file and printer sharing option

Note- Save all the changes.

Step 5- Open file explorer and go to the directory which you want to share. Now right-click on that folder and select the option of “Properties” from there.

right click on screen and go to the properties

Step 6- When the property folder gets open, go to the Sharing tab and select the “Advanced Sharing” option as well.

Sharing folders with advance settings

Step 7- Click on the “Share this folder” box.

Sometimes you may also have to set permissions on the shared folder. In that case, you can click on permissions to set the permissions.

Click on permission to sync files

Then click on the “OK button” for the further process.

Step 8- Now, from the Linux machine, open the file browser and then select the “Network” option. Then go to the “Windows-hosted folder” and start the process of data transfer.

Note: If you want to backup and restore your important data then you can use the Wondershare UBackit. It is safe and secure tool that can restore and backup your data in no time.

Bonus Tip - What Can I Do if Files Get Lost during Linux Syncing?

It is common that files may get lost when you are trying to sync them from one computer to another. But there is no need to worry about that. Recoverit data recovery makes linux data recovery easy and simple. You can retrieve your data back with 3 simple steps.

1. Select NAS and Linux

After downloading and installing Wondershare Recoverit, launch it on your computer. And select NAS and Linux from the sidebar. Then choose Linux Recovery.

click nas and linux

2. Connect the Linux Computer

After that, Recoverit will ask you for the information to connect the Linux device. Fill in the desired information, then click Connect. Once the connection is established successfully, Recoverit will start to scan the files automatically.

tap on linux recovery

3. Preview and Recover Lost Data

It will take a while to complete the scanning process. The best thing about Recoverit is that you can stop the process at any time. So if you’ve found the files you want to retrieve, you can preview and recover them instantly. Just click Recover button at the bottom right to save the file.

preview files

Video Tutorial on How to Recover Lost/Deleted Files on Linux?

Recent Videos from Recoverit

View More >

More Related: Best EaseUS Data Recovery Wizard Alternatives for Linux

Final Words

We hope the above article, you have gain knowledge on how to sync files between two Linux servers. With the help of these methods you can easily sync all your important data between Windows and Linux.

Recoverit author

Amy Dennis

staff Editor

Home > Resources > Recover Files > How to Sync Files between Two Linux Server?