Sync

caldir uses a git-like push/pull model for syncing with cloud calendar providers.

Push and pull

How sync direction is detected

Sync direction is determined by comparing timestamps and sync state:

ConditionDirection
Local file mtime > remote updatedPush (local was modified)
Remote updated > local file mtimePull (remote was modified)
Local-only event, not in sync stateNew event to push
Remote-only event, not in sync stateNew event to pull
In sync state but missing locallyDeleted locally — delete from remote on push
In sync state but missing remotelyDeleted remotely — delete locally on pull

Sync time window

By default, only events within 365 days of today (past and future) are synced. Events outside this window are left untouched locally — they’re not flagged for deletion just because they weren’t fetched from the remote.

You can override the time window with --from and --to flags:

# Pull all past events
caldir pull --from start

# Pull a specific range
caldir pull --from 2024-01-01 --to 2024-12-31

Delete sync

When you delete a local .ics file and run push, the event is also deleted from the remote. This is tracked via the sync state file (.caldir/state/known_event_ids).

Sync state

Each calendar tracks which events have been synced in .caldir/state/known_event_ids. This is a plaintext file with one event ID per line, using the RFC 5545 identity:

If the sync state file is deleted, the next pull will re-download all events and recreate it.