Syncthing

Synopsis

syncthing [serve]
          [--audit] [--auditfile=<file|-|-->] [--browser-only] [--device-id]
          [--generate=<dir>] [--gui-address=<address>] [--gui-apikey=<key>]
          [--home=<dir> | --config=<dir> --data=<dir>]
          [--logfile=<filename>] [--logflags=<flags>]
          [--log-max-old-files=<num>] [--log-max-size=<num>]
          [--no-browser] [--no-console] [--no-restart] [--paths] [--paused]
          [--no-default-folder] [--skip-port-probing]
          [--reset-database] [--reset-deltas] [--unpaused] [--allow-newer-config]
          [--upgrade] [--no-upgrade] [--upgrade-check] [--upgrade-to=<url>]
          [--verbose] [--version] [--help] [--debug-*]

syncthing generate
          [--home=<dir> | --config=<dir>]
          [--gui-user=<username>] [--gui-password=<password|->]
          [--no-default-folder] [--skip-port-probing] [--no-console]
          [--help]

syncthing decrypt (--to=<dir> | --verify-only)
          [--password=<pw>] [--folder-id=<id>] [--token-path=<file>]
          [--continue] [--verbose] [--version] [--help]
          <path>

syncthing cli
          [--home=<dir> | --config=<dir> --data=<dir>]
          [--gui-address=<address>] [--gui-apikey=<key>]
          [--help]
          <command> [command options...] [arguments...]

Description

Syncthing lets you synchronize your files bidirectionally across multiple devices. This means the creation, modification or deletion of files on one machine will automatically be replicated to your other devices. We believe your data is your data alone and you deserve to choose where it is stored. Therefore Syncthing does not upload your data to the cloud but exchanges your data across your machines as soon as they are online at the same time.

The syncthing core application is a command-line program which usually runs in the background and handles the synchronization. It provides a built-in, HTML and JavaScript based user interface to be controlled from a web browser. This frontend communicates with the core application through some HTTP APIs, which other apps like graphical system integration helpers can use as well, for greatest flexibility. A link to reach the GUI and API is printed among the first few log messages.

Options

--allow-newer-config

Try loading a config file written by a newer program version, instead of failing immediately.

--audit

Write events to timestamped file audit-YYYYMMDD-HHMMSS.log.

--auditfile=<file|-|-->

Use specified file or stream ("-" for stdout, "--" for stderr) for audit events, rather than the timestamped default file name.

--browser-only

Open the web UI in a browser for an already running Syncthing instance.

--device-id

Print device ID to command line.

--generate=<dir>

Generate key and config in specified dir, then exit.

--gui-address=<address>

Override GUI listen address. Set this to an address (0.0.0.0:8384) or file path (/var/run/st.sock, for UNIX sockets).

--gui-apikey=<string>

Override the API key needed to access the GUI / REST API.

--gui-password=<password|->

Specify new GUI authentication password, to update the config file. Read from the standard input stream if only a single dash (-) is given. The password is hashed before writing to the config file. As a special case, giving the existing password hash as password will leave it untouched.

--gui-user=<username>

Specify new GUI authentication user name, to update the config file.

--help, -h

Show help text about command line usage. Context-sensitive depending on the given subcommand.

--home=<dir>

Set common configuration and data directory. The default configuration directory is $HOME/.config/syncthing (Unix-like), $HOME/Library/Application Support/Syncthing (Mac) and %LOCALAPPDATA%\Syncthing (Windows).

--config=<dir>

Set configuration directory. Alternative to --home and must be used together with --data.

--data=<dir>

Set data (e.g. database) directory. Alternative to --home and must be used together with --config.

--logfile=<filename>

Set destination filename for logging (use "-" for stdout, which is the default option).

--logflags=<flags>

Select information in log line prefix. The --logflags value is a sum of the following:

  • 1: Date

  • 2: Time

  • 4: Microsecond time

  • 8: Long filename

  • 16: Short filename

To prefix each log line with date and time, set --logflags=3 (1 + 2 from above). The value 0 is used to disable all of the above. The default is to show time only (2).

--log-max-old-files=<num>

Number of old files to keep (zero to keep only current). Applies only when log rotation is enabled through --log-max-size.

--log-max-size=<num>

Maximum size of any log file (zero to disable log rotation).

--no-browser

Do not start a browser.

--no-console

Hide the console window. (On Windows only)

--no-default-folder

Don’t create a default folder when generating an initial configuration / starting for the first time.

--no-restart

Do not restart Syncthing when it exits. The monitor process will still run to handle crashes and writing to logfiles (if configured to).

--no-upgrade

Disable automatic upgrades. Equivalent to the STNOUPGRADE environment variable, see below.

--paths

Print the paths used for configuration, keys, database, GUI overrides, default sync folder and the log file.

--paused

Start with all devices and folders paused.

--reset-database

Reset the database, forcing a full rescan and resync. Create .stfolder folders in each sync folder if they do not already exist. Caution: Ensure that all sync folders which are mountpoints are already mounted. Inconsistent versions may result if the mountpoint is later mounted and contains older versions.

--reset-deltas

Reset delta index IDs, forcing a full index exchange.

--skip-port-probing

Don’t try to find unused random ports for the GUI and listen address when generating an initial configuration / starting for the first time.

--unpaused

Start with all devices and folders unpaused.

--upgrade

Perform upgrade.

--upgrade-check

Check for available upgrade.

--upgrade-to=<url>

Force upgrade directly from specified URL.

--verbose

Print verbose log output.

--version

Show version.

--to=<dir>

Destination directory where files should be stored after decryption.

--verify-only

Don’t write decrypted files to disk (but verify plaintext hashes).

--password=<pw>

Folder password for decryption / verification. Can be passed through the FOLDER_PASSWORD environment variable instead to avoid recording in a shell’s history buffer or sniffing from the running processes list.

--folder-id=<id>

Folder ID of the encrypted folder, if it cannot be determined automatically.

--token-path=<file>

Path to the token file within the folder (used to determine folder ID).

--continue

Continue processing next file in case of error, instead of aborting.

Exit Codes

0

Success / Shutdown

1

Error

2

Upgrade not available

3

Restarting

4

Upgrading

Exit codes over 125 are usually returned by the shell/binary loader/default signal handler. Exit codes over 128+N on Unix usually represent the signal which caused the process to exit. For example, 128 + 9 (SIGKILL) = 137.

Subcommands

The command line syntax actually supports different modes of operation through several subcommands, specified as the first argument. If omitted, the default serve is assumed.

The initial setup of a device ID and default configuration can be called explicitly with the generate subcommand. It can also update the configured GUI authentication credentials, without going through the REST API. An existing device certificate is left untouched. If the configuration file already exists, it is validated and updated to the latest configuration schema, including adding default values for any new options.

The decrypt subcommand is used in conjunction with untrusted (encrypted) devices, see the relevant section on decryption for details. It does not depend on Syncthing to be running, but works on offline data.

To work with the REST API for debugging or automating things in Syncthing, the cli subcommand provides easy access to individual features. It basically saves the hassle of handling HTTP connections and API authentication.

The available subcommands are grouped into several nested hierarchies and some parts dynamically generated from the running Syncthing instance. On every level, the --help option lists the available properties, actions and commands for the user to discover interactively. The top-level groups are:

config

Access the live configuration in a running instance over the REST API to retrieve (get) or update (set) values in a fine-grained way. The hierarchy is based on the same structure as used in the JSON / XML representations.

show

Show system properties and status of a running instance. The output is passed on directly from the REST API response and therefore requires parsing JSON format.

operations

Control the overall program operation such as restarting or handling upgrades, as well as triggering some actions on a per-folder basis.

errors

Examine pending error conditions that need attention from the user, or acknowledge (clear) them.

debug

Various tools to aid in diagnosing problems or collection information for bug reports. Some of these commands access the database directly and can therefore only work when Syncthing is not running.

- (a single dash)

Reads subsequent commands from the standard input stream, without needing to call the syncthing cli command over and over. Exits on any invalid command or when EOF (end-of-file) is received.

Proxies

Syncthing can use a SOCKS, HTTP, or HTTPS proxy to talk to the outside world. The proxy is used for outgoing connections only - it is not possible to accept incoming connections through the proxy. The proxy is configured through the environment variable all_proxy. Somewhat unusually, this variable must be named in lower case - it is not “ALL_PROXY”. For example:

$ export all_proxy=socks://192.0.2.42:8081

Development Settings

The following environment variables modify Syncthing’s behavior in ways that are mostly useful for developers. Use with care. If you start Syncthing from within service managers like systemd or supervisor, path expansion may not be supported.

STTRACE

Used to increase the debugging verbosity in specific or all facilities, generally mapping to a Go package. Enabling any of these also enables microsecond timestamps, file names plus line numbers. Enter a comma-separated string of facilities to trace. syncthing --help always outputs an up-to-date list. The valid facility strings are:

Main and operational facilities:
config

Configuration loading and saving.

db

The database layer.

main

Main package.

model

The root hub; the largest chunk of the system. File pulling, index transmission and requests for chunks.

scanner

File change detection and hashing.

versioner

File versioning.

Networking facilities:
beacon

Multicast and broadcast UDP discovery packets: Selected interfaces and addresses.

connections

Connection handling.

dialer

Dialing connections.

discover

Remote device discovery requests, replies and registration of devices.

nat

NAT discovery and port mapping.

pmp

NAT-PMP discovery and port mapping.

protocol

The BEP protocol.

relay

Relay interaction (strelaysrv).

upnp

UPnP discovery and port mapping.

Other facilities:
fs

Filesystem access.

events

Event generation and logging.

http

REST API.

sha256

SHA256 hashing package (this facility currently unused).

stats

Persistent device and folder statistics.

sync

Mutexes. Used for debugging race conditions and deadlocks.

upgrade

Binary upgrades.

walkfs

Filesystem access while walking.

all

All of the above.

STBLOCKPROFILE

Write block profiles to block-$pid-$timestamp.pprof every 20 seconds.

STCPUPROFILE

Write a CPU profile to cpu-$pid.pprof on exit.

STDEADLOCKTIMEOUT

Used for debugging internal deadlocks; sets debug sensitivity. Use only under direction of a developer.

STLOCKTHRESHOLD

Used for debugging internal deadlocks; sets debug sensitivity. Use only under direction of a developer.

STGUIADDRESS

Override GUI listen address. Equivalent to passing --gui-address.

STGUIAPIKEY

Override the API key needed to access the GUI / REST API. Equivalent to passing --gui-apikey.

STGUIASSETS

Directory to load GUI assets from. Overrides compiled in assets. Useful for developing webgui, commonly use STGUIASSETS=gui bin/syncthing.

STHASHING

Specify which hashing package to use. Defaults to automatic based on performance. Specify “minio” (compatibility) or “standard” for the default Go implementation.

STHEAPPROFILE

Write heap profiles to heap-$pid-$timestamp.pprof each time heap usage increases.

STNODEFAULTFOLDER

Don’t create a default folder when starting for the first time. This variable will be ignored anytime after the first run. Equivalent to the --no-default-folder flag.

STNORESTART

Equivalent to the --no-restart flag.

STNOUPGRADE

Disable automatic upgrades. Equivalent to the --no-upgrade flag.

STPROFILER

Set to a listen address such as “127.0.0.1:9090” to start the profiler with HTTP access, which then can be reached at http://localhost:9090/debug/pprof. See go tool pprof for more information.

STPERFSTATS

Write running performance statistics to perf-$pid.csv. Not supported on Windows.

STRECHECKDBEVERY

Time before folder statistics (file, dir, … counts) are recalculated from scratch. The given duration must be parseable by Go’s time.ParseDuration. If missing or not parseable, the default value of 1 month is used. To force recalculation on every startup, set it to 1s.

STGCINDIRECTEVERY

Sets the time interval in between database garbage collection runs. The given duration must be parseable by Go’s time.ParseDuration.

GOMAXPROCS

Set the maximum number of CPU cores to use. Defaults to all available CPU cores.

GOGC

Percentage of heap growth at which to trigger GC. Default is 100. Lower numbers keep peak memory usage down, at the price of CPU usage (i.e. performance).

LOGGER_DISCARD

Hack to completely disable logging, for example when running benchmarks. Set to any nonempty value to use it.

See Also

syncthing-config(5), syncthing-stignore(5), syncthing-device-ids(7), syncthing-security(7), syncthing-networking(7), syncthing-versioning(7), syncthing-faq(7)