feat(sync): enable scheduled asset synchronization mode

This update introduces a persistent background synchronization mode, allowing the external assets container to run continuously and periodically sync albums instead of executing once and exiting. The system now checks a configurable interval, retries on temporary failures, and manages its lifecycle using `time.sleep`.

- Added SYNC_INTERVAL_SECONDS configuration for scheduling
- Updated compose service to restart automatically and loop indefinitely
- Implemented continuous run logic in main function and added corresponding unit tests
This commit is contained in:
2026-07-23 14:04:13 +02:00
parent 22dcae73ba
commit 7a43db8dd8
5 changed files with 89 additions and 7 deletions
+6 -3
View File
@@ -37,6 +37,8 @@ Optional environment variables:
- `ALBUM_SEPARATOR`: Separator for `relative` mode; defaults to ` - `
- `PAGE_SIZE`: Immich search page size; defaults to `1000`
- `DRY_RUN`: Set to `true` to log planned work without changing albums
- `SYNC_INTERVAL_SECONDS`: Delay between runs; `0` runs once and exits.
Docker Compose defaults to `1800` seconds (30 minutes)
Run the script after Immich has scanned the external library:
@@ -68,9 +70,10 @@ The photo directory does not need to be mounted into this container:
`EXTERNAL_ROOT` is matched against the path recorded in Immich's
`originalPath` field.
The Compose service performs one synchronization and then exits. Run it after
an external-library scan, or invoke it regularly with a scheduler such as
cron.
The Compose service stays running and synchronizes every 30 minutes. Change
`SYNC_INTERVAL_SECONDS` in `.env` to use another interval. The delay starts
after a synchronization finishes. Temporary API errors are logged and retried
on the next scheduled run.
The script only adds missing assets. It never removes assets from albums and
never deletes albums.