Syncthing is one of the most powerful self-hosted file synchronization tools available, but many users barely scratch the surface of its capabilities. While getting basic sync working is straightforward, mastering advanced features like ignore patterns, versioning strategies, and relay server configuration can transform Syncthing from a simple sync tool into a robust backup and collaboration system.

đź’ˇ This article contains affiliate links. If you buy through them, we earn a small commission at no extra cost to you. Learn more.

In this comprehensive guide, we’ll dive deep into three critical advanced features that will help you fine-tune your Syncthing setup for maximum efficiency and data protection. Whether you’re syncing development projects, backing up important documents, or coordinating files across multiple devices, these techniques will give you precise control over what syncs, how it’s protected, and how devices connect.

Understanding Syncthing Ignore Patterns

Ignore patterns are one of the most useful yet underutilized features in Syncthing. They allow you to exclude specific files and directories from synchronization, which is essential when dealing with build artifacts, cache files, temporary data, or sensitive information that shouldn’t be shared across all devices.

How Ignore Patterns Work

Syncthing uses .stignore files placed in the root of each synchronized folder. These files use a syntax similar to .gitignore, making them familiar to developers. The patterns are processed line by line, and you can use wildcards, negation, and comments to create sophisticated rules.

Basic Ignore Pattern Syntax

Create a .stignore file in your synced folder with patterns like these:

// Comments start with double slashes
// Ignore all .tmp files
*.tmp

// Ignore the entire cache directory
cache/

// Ignore all log files in any directory
**/*.log

// Ignore node_modules everywhere
**/node_modules

// Negation: ignore everything except specific files
*
!important.txt
!*.md

Wildcard Patterns Explained

Syncthing supports several wildcard types:

  • * — Matches any sequence of characters except path separators
  • ** — Matches any sequence including path separators (entire directory trees)
  • ? — Matches any single character except path separator
  • [abc] — Matches one character from the set
  • [a-z] — Matches one character from the range

Practical Ignore Pattern Examples

For Development Projects:

// Build outputs
build/
dist/
target/
*.o
*.exe

// Dependencies (download fresh on each machine)
node_modules/
vendor/
__pycache__/

// IDE and editor files
.vscode/
.idea/
*.swp
*.swo
*~

// OS-specific files
.DS_Store
Thumbs.db
desktop.ini

For Photo Libraries:

// Ignore camera-generated preview files
*.THM
.picasa*
.thumbnails/

// Ignore editing software cache
**/Adobe Photoshop Auto-Recover/
**/Capture One/Cache/

For Document Sync:

// Ignore temporary Office files
~$*
*.tmp

// Ignore backup files
*.bak
*~

// Ignore large media while syncing documents
*.mp4
*.mkv
*.avi

Advanced Pattern Techniques

Case Sensitivity:

By default, patterns are case-sensitive on Linux/Unix and case-insensitive on Windows/macOS. You can force case-insensitive matching by prefixing with (?i):

(?i)*.jpg  // Matches .jpg, .JPG, .Jpg, etc.

Prefix Patterns:

Use ! to negate a pattern (include files that would otherwise be ignored):

*.log        // Ignore all logs
!important.log  // But keep this one

Directory-Only Patterns:

Trailing slash means “directories only”:

temp/   // Ignores directory named temp
temp    // Ignores files AND directories named temp

Testing Ignore Patterns

Before committing to complex ignore patterns, test them using the Syncthing web UI:

  1. Navigate to the folder settings
  2. Click “Edit” next to “Ignore Patterns”
  3. Enter your patterns
  4. Use the “Preview” tab to see which files will be ignored

The preview shows real files from your sync folder matched against your patterns, helping you catch mistakes before they cause unwanted behavior.

Implementing File Versioning Strategies

Versioning is Syncthing’s safety net against accidental deletions, overwrites, and ransomware. When enabled, Syncthing keeps old versions of files before they’re modified or deleted, giving you the ability to recover from mistakes.

Why Versioning Matters

Without versioning, Syncthing synchronizes changes immediately. If you accidentally delete a file on one device, it’s deleted everywhere within seconds. If malware corrupts files, those corrupted versions sync to all devices. Versioning prevents these disaster scenarios.

The Five Versioning Methods

Syncthing offers five versioning strategies, each suited to different use cases:

1. Trash Can Versioning

How it works: Deleted or modified files are moved to a .stversions folder and kept for a configurable number of days.

Best for: General-purpose use, document folders, casual backups

Configuration:

  • Clean out after: 30 days (default)

Example: If you delete document.txt, it moves to .stversions/document.txt~20260224-050000 and stays there for 30 days before permanent deletion.

Pros:

  • Simple and intuitive
  • Automatic cleanup saves disk space
  • Easy to recover recent deletions

Cons:

  • No versioning for modified files after the retention period
  • Large files can accumulate quickly

2. Simple Versioning

How it works: Keeps a specified number of old versions of each file.

Best for: Configuration files, code files, documents with frequent edits

Configuration:

  • Keep versions: 5 (keeps last 5 versions of each file)

Example: After editing config.yaml five times, you’ll have:

  • config.yaml (current)
  • .stversions/config.yaml~20260224-050000
  • .stversions/config.yaml~20260223-120000
  • … (up to 5 versions)

Pros:

  • Predictable storage usage per file
  • Great for tracking recent changes
  • Works well for text files and configs

Cons:

  • No time-based retention
  • All files get same number of versions regardless of importance

3. Staggered Versioning

How it works: Keeps versions at increasing time intervals — many recent versions, fewer old versions.

Best for: Long-term document archival, important project files, photo libraries

Configuration:

  • Maximum age: 365 days
  • Versions path: .stversions (can be on external drive)

Retention schedule:

  • Versions from last hour: All versions
  • Versions from last day: One per hour
  • Versions from last 30 days: One per day
  • Versions from last year: One per month
  • Older than one year: Deleted

Example: A file edited 100 times over a year will have versions from today, yesterday, last week, last month, etc., using far less space than keeping all 100 versions.

Pros:

  • Excellent balance between coverage and storage
  • Long-term protection without massive storage requirements
  • Great for important data that changes frequently

Cons:

  • More complex to understand
  • Can’t guarantee specific version count

4. External Versioning

How it works: Runs a custom command or script when a file is modified/deleted.

Best for: Integration with existing backup systems, custom archival workflows, advanced users

Configuration:

  • Command: Custom script path with variables

Example command:

1
/usr/local/bin/backup.sh %FOLDER_PATH% %FILE_PATH%

Variables available:

  • %FOLDER_PATH% — Syncthing folder root
  • %FILE_PATH% — Relative path to the file

Pros:

  • Unlimited flexibility
  • Can integrate with rsync, rclone, git, or backup software
  • Can version to remote storage or different drives

Cons:

  • Requires scripting knowledge
  • No built-in UI for recovery
  • Debugging can be complex

5. No Versioning

How it works: Disabled — files are overwritten/deleted immediately.

Best for: Cache folders, temporary files, disposable data

Use case: When you’re syncing data that’s already backed up elsewhere or is intentionally ephemeral.

Choosing the Right Versioning Strategy

For personal documents and photos: Staggered versioning (365 days)

For development projects: Simple versioning (keep 10-15 versions) or use external versioning with Git

For configuration files: Simple versioning (keep 5 versions)

For media libraries synced from a NAS: Trash can versioning (7 days) or no versioning if the NAS has its own snapshots

For critical business data: Staggered versioning + external backup script

Versioning Best Practices

  1. Store versions on a different drive — Use the “Versions Path” option to point to an external USB drive or NAS to protect against disk failure

  2. Monitor storage usage — Check .stversions folder size regularly; versioning can consume significant space

  3. Combine strategies — Use different versioning per folder based on importance and change frequency

  4. Test recovery — Periodically practice restoring files from versions to ensure the system works

  5. Consider immutable backups — For ransomware protection, combine versioning with offline backups

Recovering Versioned Files

To restore a versioned file:

  1. Navigate to the synced folder
  2. Open the .stversions directory
  3. Find the file with timestamp: filename~20260224-050000
  4. Copy it back to the main folder and remove the timestamp suffix

For large-scale recovery, use command line:

1
2
3
4
5
# Find all versions of a specific file
find .stversions -name "document.txt~*"

# Restore latest version
cp .stversions/document.txt~20260224-050000 document.txt

Optimizing Relay Server Configuration

Syncthing devices prefer to connect directly to each other, but when both devices are behind NAT or firewalls, relay servers provide a fallback connection method. Understanding and optimizing relay usage can dramatically improve sync performance and reliability.

How Relay Servers Work

When two Syncthing devices can’t establish a direct connection, they fall back to relay servers — intermediate servers that pass data between devices. This ensures synchronization works even in restrictive network environments.

Connection priority:

  1. Direct LAN — Local network (fastest)
  2. Direct WAN — Direct internet connection via NAT traversal
  3. Relay — Through a relay server (slowest but most compatible)

Public Relays vs Private Relays

Public Relays:

  • Run by volunteers in the Syncthing community
  • Free to use
  • Variable performance and availability
  • Data is end-to-end encrypted (relays can’t read your data)
  • Bandwidth-limited to prevent abuse

Private Relays:

  • Self-hosted on your own server (VPS or dedicated machine)
  • Full control over performance and availability
  • No bandwidth limits
  • Ideal for large file transfers when direct connection fails
  • Requires a server with a public IP address

Configuring Relay Usage

In the Web UI:

  1. Navigate to Actions → Settings → Connections
  2. Enable/disable relay servers globally
  3. Set relay priority and rate limits

Key settings:

  • Enable Relaying: On/Off
  • Relay Rate Limits: Set max upload/download speeds for relay connections
  • Relay Reconnect Interval: How often to retry relay connections
  • Relay Pool Servers: Default public pool or custom relay list

When to Use Relays

Enable relays when:

  • Syncing between devices on different restricted networks (corporate, university)
  • One device is on mobile network with strict NAT
  • No UPnP/NAT-PMP support on routers
  • Prioritizing reliability over speed

Disable relays when:

  • All devices are on the same local network
  • You can configure port forwarding manually
  • Concerned about relying on third-party infrastructure
  • All devices have public IPs or working NAT traversal

Setting Up Your Own Relay Server

Running a private relay gives you full control and better performance. You’ll need a VPS or dedicated server with a public IP.

Requirements:

  • Linux server with public IP
  • 1GB RAM minimum
  • Open port (default 22067)
  • Basic server administration skills

Installation on Ubuntu/Debian:

1
2
3
4
5
6
7
# Download the latest Syncthing relay server
wget https://github.com/syncthing/relaysrv/releases/latest/download/relaysrv-linux-amd64.tar.gz
tar -xzf relaysrv-linux-amd64.tar.gz
sudo mv relaysrv /usr/local/bin/

# Create systemd service
sudo nano /etc/systemd/system/relaysrv.service

Service file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
[Unit]
Description=Syncthing Relay Server
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/relaysrv -pools="" -global-rate=1000000
Restart=always
User=syncthing
Group=syncthing

[Install]
WantedBy=multi-user.target

Start the service:

1
2
3
sudo systemctl enable relaysrv
sudo systemctl start relaysrv
sudo systemctl status relaysrv

Use your private relay:

In Syncthing settings, set custom relay pool:

relay://your-server-ip:22067

Monitoring Relay Performance

Check which connection type is active:

  1. Open Syncthing Web UI
  2. Navigate to a connected device
  3. Look for connection details: “Direct (LAN)”, “Direct (WAN)”, or “Relay”

CLI monitoring:

1
2
# Check relay status
curl http://127.0.0.1:8384/rest/system/connections

Look for "type": "relay" in the output.

Relay Security Considerations

Data encryption: All data passing through relays is end-to-end encrypted. Relay operators cannot read your files.

Metadata exposure: Relay servers can see:

  • Device IDs communicating
  • Data volume transferred
  • Connection timestamps

Mitigation:

  • Use your own relay server for sensitive sync
  • Or ensure direct connections work (port forwarding, VPN)

Optimizing Relay Performance

1. Geographic proximity: Choose relay servers close to both syncing devices

2. Set rate limits appropriately:

relaysrv -global-rate=10000000  // 10 MB/s max

3. Multiple relays: Configure multiple relay addresses for redundancy:

relay://relay1.example.com:22067,relay://relay2.example.com:22067

4. Monitor and disable slow relays: Remove underperforming relays from your configuration

5. Use relay as last resort: Ensure NAT traversal is properly configured first

Combining Advanced Features for Maximum Effectiveness

The real power comes from combining these features strategically:

Example 1: Developer Workspace

  • Ignore patterns: Exclude node_modules, build output, IDE configs
  • Versioning: Simple (10 versions) for code files
  • Relays: Enabled for syncing between home and office through corporate firewall

Example 2: Family Photo Library

  • Ignore patterns: Exclude camera thumbnails, cache files
  • Versioning: Staggered (365 days) on external drive
  • Relays: Disabled (all devices on home network or VPN)

Example 3: Document Sync Across Devices

  • Ignore patterns: Exclude temp files, backups
  • Versioning: Trash can (30 days) for easy recovery
  • Relays: Enabled with private relay server for mobile device sync

Troubleshooting Common Issues

Ignore patterns not working:

  • Check .stignore file is in the folder root
  • Verify pattern syntax (test in web UI preview)
  • Remember: patterns don’t retroactively remove already-synced files

Versioning consuming too much space:

  • Reduce retention period
  • Switch to staggered versioning
  • Move .stversions to larger external storage

Always using relay despite being on same network:

  • Check firewall rules allow Syncthing ports (22000 TCP/UDP by default)
  • Enable UPnP on router if supported
  • Verify “Local Discovery” is enabled in Syncthing settings

Relay connections slow or unreliable:

  • Set up your own private relay server
  • Check relay rate limits aren’t too restrictive
  • Verify direct connection isn’t possible (preferred)

Conclusion

Mastering Syncthing’s advanced configuration features transforms it from a simple sync tool into a comprehensive file management and protection system. Ignore patterns give you surgical control over what syncs, versioning protects against data loss and ransomware, and relay optimization ensures connectivity in any network environment.

Start with basic configurations and gradually refine them based on your actual usage patterns. Monitor storage consumption from versioning, test your ignore patterns thoroughly, and benchmark whether relay connections are necessary or if direct connections can be established.

With these advanced techniques, you’ll have a self-hosted synchronization system that rivals commercial cloud services while maintaining complete privacy and control over your data.

Key takeaways:

  • Use .stignore files to exclude unnecessary files from sync
  • Choose versioning strategy based on data importance and change frequency
  • Enable relays for reliability, but optimize for direct connections when possible
  • Combine features strategically for different folder types
  • Monitor storage usage and connection types regularly

Whether you’re protecting critical business data or just keeping your personal files in sync across devices, these advanced Syncthing features give you the tools to build a robust, efficient, and secure synchronization infrastructure.