Syncthing: Difference between revisions

From wikinotes
 
(11 intermediate revisions by the same user not shown)
Line 9: Line 9:
|-
|-
| docs: firewall || https://docs.syncthing.net/users/firewall.html
| docs: firewall || https://docs.syncthing.net/users/firewall.html
|-
| docs: rest api || https://docs.syncthing.net/dev/rest.html
|-
|-
| docs: cli || https://docs.syncthing.net/users/syncthing.html
| docs: cli || https://docs.syncthing.net/users/syncthing.html
Line 49: Line 51:
= Configuration =
= Configuration =
<blockquote>
<blockquote>
== Web UI ==
<blockquote>
{{ NOTE |
You don't need to expose the UI to the public facing internet, only the synchronization ports.
}}
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<configuration version="37">
<configuration version="37">
Line 56: Line 64:
</configuration>
</configuration>
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Web UI -->
== Web API ==
<blockquote>
You shouldn't change the settings files by hand while syncthing is running,<br>
but you can use a REST-API to request that changes are made (and applied dynamically)
<syntaxhighlight lang="bash">
API_KEY="$(cat config.xml | dasel -r xml '.configuration.gui.apikey')"
API_URL="http://$(cat config.xml | dasel -r xml '.configuration.gui.address')/rest"
curl -X GET -H "X-API-KEY: ${API_KEY}" "${API_URL}/${ROUTE}"
curl -X GET -H "X-API-KEY: ${API_KEY}" -d @/dev/stdin "${API_URL}/${ROUTE}"
</syntaxhighlight>
Some sample routes:
<syntaxhighlight lang="bash">
GET config/devices              # list devices
GET config/folders              # list folders
PUT config/devices/${device_id}  # create device
PUT config/folders/${device_id}  # create folder
</syntaxhighlight>
</blockquote><!-- Cli -->
== Notable Settings ==
<blockquote>
Some common settings
{| class="wikitable"
|-
!colspan=1| setting
!colspan=1| default
!colspan=1| description
|-
|-
| [https://docs.syncthing.net/users/config.html#config-option-folder.rescanintervals rescanIntervalS] || 60 || interval that a full-rescan of all files occurs
|-
| [https://docs.syncthing.net/users/config.html#config-option-folder.fswatcherdelays fsWatcherDelayS] || 10 || fs-watcher changes are collected, and sent to the server at this interval
|-
|}
</blockquote><!-- Notable Settings -->
</blockquote><!-- Configuration -->
</blockquote><!-- Configuration -->


Line 92: Line 140:
syncthing UI:
syncthing UI:
   - Add Remote Device:
   - Add Remote Device:
</syntaxhighlight>
When configuring the address, you only need to specify the '''sync port''', not the webui.<br>
You can also use '''dynamic''', which will try to identify the device on your local network.<br>
You can also use a combination of the two, connecting on your local network if available, but falling back on a public host/port.
<syntaxhighlight lang="yaml">
Address: tcp://foo.com:22000,dynamic  # combination of sync addresses
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Sharing Device IDs -->
</blockquote><!-- Sharing Device IDs -->
Line 109: Line 165:
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Sharing Folders -->
</blockquote><!-- Sharing Folders -->
== Ignore Patterns ==
<blockquote>
The <code>.stignore</code> file at the root of your file share determines which files will not be synchronized.<br>
It uses the same glob matching syntax as <code>.gitignore</code>, <code>.ignore</code> etc.
<syntaxhighlight lang="bash">
# example:
ignore-me
**/*.ignore-me
</syntaxhighlight>
</blockquote><!-- Ignore Patterns -->
</blockquote><!-- Usage -->
</blockquote><!-- Usage -->

Latest revision as of 18:12, 29 July 2023

self-hosted file synchronization tool written in go.
one server install can host, and control access to multiple shared folders.

Documentation

official docs https://docs.syncthing.net/
docs: firewall https://docs.syncthing.net/users/firewall.html
docs: rest api https://docs.syncthing.net/dev/rest.html
docs: cli https://docs.syncthing.net/users/syncthing.html
github https://github.com/syncthing/syncthing
home https://syncthing.net/

Locations

${syncthing_home}/config.xml depending on config, maybe user-home, or daemon-home
http://127.0.0.1:8384 default web-ui
TCP 22000 TCP based sync
UDP 22000 QUIC based sync
UDP 21027 (optional) discovery broadcasts ipv4, multicast ipv6

Clients

mobius sync ios synchronization client
syncthing-gtk UI/systemtray for syncthing

Configuration

Web UI

NOTE:

You don't need to expose the UI to the public facing internet, only the synchronization ports.

<configuration version="37">
  <gui enabled="true" tls="true" debugging="false">
    <address>127.0.0.1:8384</address>
  </gui>
</configuration>

Web API

You shouldn't change the settings files by hand while syncthing is running,
but you can use a REST-API to request that changes are made (and applied dynamically)

API_KEY="$(cat config.xml | dasel -r xml '.configuration.gui.apikey')"
API_URL="http://$(cat config.xml | dasel -r xml '.configuration.gui.address')/rest"

curl -X GET -H "X-API-KEY: ${API_KEY}" "${API_URL}/${ROUTE}"
curl -X GET -H "X-API-KEY: ${API_KEY}" -d @/dev/stdin "${API_URL}/${ROUTE}"

Some sample routes:

GET config/devices               # list devices
GET config/folders               # list folders
PUT config/devices/${device_id}  # create device
PUT config/folders/${device_id}  # create folder

Notable Settings

Some common settings

setting default description
rescanIntervalS 60 interval that a full-rescan of all files occurs
fsWatcherDelayS 10 fs-watcher changes are collected, and sent to the server at this interval

Install

pacaur -S syncthing

sudo systemctl --user enable syncthing.service
sudo systemctl --user start syncthing.service
pkg install syncthing

# rc.conf
syncthing_enable="YES"
syncthing_home="/usr/local/etc/syncthing"
syncthing_user="syncthing"
syncthing_group="syncthing"

Usage

Sharing Device IDs

Before computers can share a folder, both must add the other's device ID.

# on one syncthing
syncthing-gtk
  - Settings: Show ID

# on the other
syncthing UI:
  - Add Remote Device:

When configuring the address, you only need to specify the sync port, not the webui.
You can also use dynamic, which will try to identify the device on your local network.
You can also use a combination of the two, connecting on your local network if available, but falling back on a public host/port.

Address: tcp://foo.com:22000,dynamic  # combination of sync addresses

Sharing Folders

After each device has added the other, you can share existing folders.
From the computer with the share, choose to share with the other.

Folders: org-mode
  - Edit:
    - Tab: Sharing
    - Unshared Devices:
      - [x] your-other-device
    - Save

Ignore Patterns

The .stignore file at the root of your file share determines which files will not be synchronized.
It uses the same glob matching syntax as .gitignore, .ignore etc.

# example:
ignore-me
**/*.ignore-me