Skip to main content

Versioning and File History

File versioning in Syncthing preserves old copies of files when they are modified or deleted by a remote peer. It acts as a local undo buffer.

warning

Syncthing versioning only triggers on changes received from remote peers. If you locally delete a file, it is not versioned — it's just deleted. This is a critical distinction.

Learning Focus

Use versioning as an emergency safety net, not a primary backup strategy. For true backup, use Restic.

Where Versions Are Stored

All version history is stored in a hidden .stversions directory inside the synced folder:

/var/www/html/uploads/
├── images/
│ └── photo.jpg ← current file
└── .stversions/
└── images/
└── photo.jpg~20260413-091523 ← old version

The Four Versioning Modes

1. No File Versioning (Default)

No old versions are kept. A deletion from a peer results in immediate local deletion with no recovery option.

Best for: Folders where disk space is critical and recovery is handled by a separate backup system (restic).

2. Trash Can Versioning

Deleted or replaced files are moved to .stversions and kept for a configurable number of days.

SettingDescription
Clean out afterNumber of days to keep old versions (default: 30)
Day 0: peer deletes photo.jpg
→ Moved to .stversions/images/photo.jpg~20260413-091523

Day 30: cleanup runs
→ photo.jpg~20260413-091523 is permanently deleted

Best for: Casual use, desktop machines. Simple time-based cleanup.

3. Simple Versioning

Keep the last N versions of a file. On overflow, the oldest version is deleted.

SettingDescription
Keep versionsNumber of versions to retain per file (default: 5)
photo.jpg~1 (oldest)
photo.jpg~2
photo.jpg~3
photo.jpg~4
photo.jpg~5 (newest)

→ On 6th change: photo.jpg~1 is deleted, others shift

Best for: Folders where you need a fixed-depth undo history per file.

4. Staggered Versioning

The most sophisticated option. Keeps more recent versions at fine granularity and fewer older versions at coarse granularity, similar to Grandfather-Father-Son (GFS) retention.

PeriodGranularity
Last hourOne version per 30 seconds
Last dayOne version per hour
Last monthOne version per day
Beyond thatOne version per week

Best for: Production servers, NAS devices, media libraries. Gives you fine-grained recent history plus long-term retention without unlimited disk growth.

Configuring Versioning in the GUI

  1. Expand the folder card → Edit.
  2. Go to the Versioning tab.
  3. Choose the versioning type from the dropdown.
  4. Configure the parameters (days, count, etc.).
  5. Click Save.

Recovering a File from Versions

Version files are just regular files in .stversions. Recovering is a manual process:

recover-from-versions.sh
# List all versions of a specific file
ls -la /var/www/html/uploads/.stversions/images/photo.jpg*

# Recover a specific version by copying it back
cp "/var/www/html/uploads/.stversions/images/photo.jpg~20260413-091523" \
/var/www/html/uploads/images/photo.jpg

# Syncthing will detect the restored file and sync it to peers
note

When you copy a file back from .stversions, Syncthing treats it as a new local change and syncs it to all peers — effectively performing a distributed rollback.

Disk Space Planning

Staggered versioning can accumulate significant disk usage on busy folders. Monitor it:

# Check size of version history
du -sh /var/www/html/uploads/.stversions

# Find the largest version files
find /var/www/html/uploads/.stversions -type f -printf '%s %p\n' \
| sort -rn | head -20 | numfmt --to=iec

Summary: When to Use Each Mode

ModeDisk UsageRecovery EaseBest For
NoneMinimalNoneDisk-constrained + external backup
Trash CanLow (time-based)EasyDesktops and laptops
SimpleFixedEasyDev/test folders
StaggeredMedium (grows over time)EasyProduction, media libraries

What's Next