I wanted to share files on multiple PCs without git push
, so I tried Syncthing
introduced by the company!
Official repository https://github.com/syncthing/syncthing/
Syncthing is a continuous file synchronization program. It synchronizes files between two or more computers. (From the official repository)
The literal translation is "Share files between two or more PCs."
It's similar to DropBox and OneDrive, but unlike these, the files aren't uploaded to the server.
As of March 2020, the following are supported.
I have a Mac and Ubuntu at hand, so I'll try them with these two. First, I will describe the setting procedure with GUI, but since it seems that it can be done only with CLI, I will describe it later.
Ubuntu
reference https://apt.syncthing.net/
curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
sudo apt update && sudo apt install syncthing
#Execute → Browser starts up
syncthing
Mac
brew install syncthing
#Execute → Browser starts up
syncthing
I have not confirmed it because there is no environment, but it seems that binary installation can also be done like the following site. https://computingforgeeks.com/install-and-configure-syncthing-on-centos-linux/
Android
I haven't confirmed this because there is no environment, but there is an app in the store. https://play.google.com/store/apps/details?id=com.nutomic.syncthingandroid&hl=ja
When you execute the syncthing
command, the browser will be launched and the following screen will be displayed.
If you execute the syncthing
command according to the above procedure, synchronization will not be possible unless you leave the console running, so register it as a service.
Ubuntu
sudo systemctl enable syncthing@${USER}.service
sudo systemctl start syncthing@${USER}.service
Mac
brew services start syncthing
On Mac, Syncthing starts up, but I can't see the web GUI ... If it is already set, synchronization will be performed properly.
If you want to launch the Web GUI on Mac, use the separate syncthing -browser-only
command.
There are the following steps to synchronize.
syncthing
on all the devices you want to syncSince 1. is completed, we will explain from 2.
There is an "Add connected device" button at the bottom right of the screen displayed on the browser, so press it. Then, the following pop-up will be displayed.
If the devices to be synchronized are on the same network with syncsync
running up
The device ID of the other device will be displayed automatically, so you can just select it.
If they do not exist on the same network, you need to find out and enter the device ID.
You can check the device ID by selecting Menu → Show ID at the top right of the screen.
Set the above settings for 2 units.
This time I will try to synchronize the ~ / github
folder of Ubuntu.
There is an "Add Folder" button on the left side of the browser of the synchronization source, so press it.
Then, the following pop-up will be displayed. Specify the folder you want to share in the folder name. I happened to be a folder in my home directory, so it's okay as it is, but in other cases, set the folder path as well.
Make a note of this folder ID
as it is important.
There is a ignore filename
tab on the pop-up, so you can exclude files you don't want to share here.
I did it directly in the config file.
https://docs.syncthing.net/users/ignoring.html
Make the same settings at the synchronization destination.
The point is to make the folder ID
the same.
Click the edit button of the connected device.
Press Share
in the displayed popup, check the folder you want to share in Folder to share with this device
, and save.
If the synchronization setting is successful, you just have to wait for the synchronization to start as shown below!
With the default settings, you can only open the web GUI screen from localhost. Therefore, if you change the settings so that the Web GUI can be displayed from the outside, you can easily set the settings even in a CLI-only environment.
However, in a public environment such as VPS or EC2, anyone can change the setting, so be sure to set a password.
The location of the configuration file differs depending on the environment.
--For Linux
~/.config/syncthing/config.xml
--For Mac
~/Library/ApplicationSupport/Syncthing/config.xml
Since there is a GUI setting, modify it as follows.
before
<gui enabled="true" tls="false" debugging="false">
<address>127.0.0.1:8384</address>
<apikey>aNw6DrLYWukHvLK22Ed7M5hoR5tixPJG</apikey>
<theme>dark</theme>
</gui>
after
<gui enabled="true" tls="false" debugging="false">
<!--0 here.0.0.Fixed to 0-->
<address>0.0.0.0:8384</address>
<apikey>aNw6DrLYWukHvLK22Ed7M5hoR5tixPJG</apikey>
<theme>dark</theme>
</gui>
If syncthing is running, restart syncthing.
Now you can see it from the outside, but as mentioned above, it's in a public state, so you'll get a warning.
Click the Settings
button at the bottom right and set the GUI user and password.
It was also possible to set it completely on the command line just by setting config.xml
.
However, it was a bit annoying because I need to edit the XML directly & it needs to be described on all multiple terminals.
Although it is light, I will describe the setting method.
The installation procedure is exactly the same as above.
I think there is a device
tag, so copy this content and set it directly below.
Set the id of the device you want to synchronize with the id of the device.
<device id="XXXXXXXXX" name="xxx-ubuntu" compression="metadata" introducer="false" skipIntroductionRemovals="false" introducedBy="">
<address>dynamic</address>
<paused>false</paused>
<autoAcceptFolders>false</autoAcceptFolders>
<maxSendKbps>0</maxSendKbps>
<maxRecvKbps>0</maxRecvKbps>
<maxRequestKiB>0</maxRequestKiB>
</device>
The device ID is the log displayed when the syncthing
command is executed, the WEB screen in the case of GUI, and the service (daemon) in the case of execution.
Check from the following command.
syncthing -device-id
There is a tag of folder id =" default "
at the top of config.xml
, so copy all of this and set it directly below.
<folder id="default" label="Default Folder" path="/Users/xxxx/Sync" type="sendreceive" rescanIntervalS="3600" fsWatcherEnabled="true" fsWatcherDelayS="10" ignorePerms="false" autoNormalize="true">
<filesystemType>basic</filesystemType>
<device id="XXXXXXXXX" introducedBy=""></device>
<minDiskFree unit="%">1</minDiskFree>
<versioning></versioning>
<copiers>0</copiers>
<pullerMaxPendingKiB>0</pullerMaxPendingKiB>
<hashers>0</hashers>
<order>random</order>
<ignoreDelete>false</ignoreDelete>
<scanProgressIntervalS>0</scanProgressIntervalS>
<pullerPauseS>0</pullerPauseS>
<maxConflicts>-1</maxConflicts>
<disableSparseFiles>false</disableSparseFiles>
<disableTempIndexes>false</disableTempIndexes>
<paused>false</paused>
<weakHashThresholdPct>25</weakHashThresholdPct>
<markerName>.stfolder</markerName>
<copyOwnershipFromParent>false</copyOwnershipFromParent>
<modTimeWindowS>0</modTimeWindowS>
</folder>
Rewrite the following part of the copied settings.
After changing the settings, restart syncthing
.
Setting Example
example
<folder id="github-folder-id" label="github" path="/Users/xxxxx/github" type="sendreceive" rescanIntervalS="3600" fsWatcherEnabled="true" fsWatcherDelayS="10" ignorePerms="false" autoNormalize="true">
<filesystemType>basic</filesystemType>
<device id="Device ID 1" introducedBy=""></device>
<device id="Device ID 2" introducedBy=""></device>
<device id="Device ID 3" introducedBy=""></device>
<minDiskFree unit="%">1</minDiskFree>
<versioning></versioning>
<copiers>0</copiers>
<pullerMaxPendingKiB>0</pullerMaxPendingKiB>
<hashers>0</hashers>
<order>random</order>
<ignoreDelete>false</ignoreDelete>
<scanProgressIntervalS>0</scanProgressIntervalS>
<pullerPauseS>0</pullerPauseS>
<maxConflicts>-1</maxConflicts>
<disableSparseFiles>false</disableSparseFiles>
<disableTempIndexes>false</disableTempIndexes>
<paused>false</paused>
<weakHashThresholdPct>25</weakHashThresholdPct>
<markerName>.stfolder</markerName>
<copyOwnershipFromParent>false</copyOwnershipFromParent>
<modTimeWindowS>0</modTimeWindowS>
</folder>
that's all. Let's use it for a while and check its usability.
Recommended Posts