syncthing-file-replication
Syncthing file replication using ubuntu 22.04
SyncThing is a peer-to-peer file sync service, meaning that your devices form a direct connection instead of storing files on someone else's servers. If all those devices are on the same network, your files never leave that network (though SyncThing can work remotely as well).
Installation
Update the package list and install Syncthing:
apt update
apt install syncthing
Starting Syncthing Service
Enable and start the Syncthing service:
systemctl enable syncthing@root.service
systemctl start syncthing@root.service
systemctl status syncthing@root.service
Configuring Syncthing
Update the config.xml file located at /root/.config/syncthing/config.xml. Modify the <gui> section with the following:
`
<gui enabled="true" tls="false" debugging="false">
<address>0.0.0.0:8384</address>
<apikey>EyKiG4cPR36uh5oVVpbXsmNEmysV6Gna</apikey>
<theme>default</theme>
</gui>
Restart Syncthing
After updating the config file, restart the Syncthing service:
sudo systemctl restart syncthing@root.service
Replace /root with the appropriate user's home directory if you want to run Syncthing as a different user.
Web UI Setup
Note: Ensure that your firewall allows traffic on port 8384 for Syncthing to function correctly.
Update Web UI Credentials:
- Access the Syncthing web UI at
http://<your-ip>:8384. - Update the username and password for the web UI.
Configure Connection Settings:
- Navigate to Actions in the Web UI and go to Connections.
- Uncheck the following options: Enable NAT traversal, Local Discovery, Global Discovery, Enable Relaying.
Add Remote Devices
Identify Device ID:
- On Syncthing2 server, click Actions, then choose Show ID. Copy the displayed device ID (e.g.,
XXXXX-XXXXX-SHTW7GI-E47AB5L-XXXXX-WITFGX6-XXXXX-TPXI7Q7).
Add Remote Devices:
- On Syncthing1 server, click on Add remote device in the general tab.
- Paste the copied device ID and provide a name for Syncthing2.
- In the Advanced tab, set the address to
tcp://syncthing2-ip:22000and select compressionoff. - Repeat the process for Syncthing2 using the device ID from Syncthing1.
Set Up Folder Replication
Add Replication Folder:
- Click on Add Folder in the general tab.
- Enter the folder label (e.g.,
/srv/) and the corresponding folder path. - Navigate to the Sharing tab and select the Syncthing1 checkbox to share the folder.
- In the Advanced tab, set Full Rescan Interval (s) to 600 seconds, and Folder Type to Send & Receive. Save the changes.
Notify Syncthing2:
- Syncthing1 will notify Syncthing2 to add the folder; confirm the action.
Repeat for Syncthing2:
- Redo the same steps on Syncthing2, adding the folder shared by Syncthing1.