A Python script that synchronizes photos and videos between two Immich accounts while respecting deletions and maintaining sync state.
- Bidirectional Sync: Synchronizes assets between two Immich accounts in both directions
- Date Range Filtering: Only syncs assets within a specified date range
- Deletion Awareness: Respects deletions - won't re-sync assets that were intentionally deleted
- Duplicate Prevention: Tracks synced assets to avoid duplicate uploads
- Continuous Operation: Can run continuously with configurable intervals
- Comprehensive Logging: Detailed logging to both file and console
- SQLite Database: Maintains sync state and deletion history in a local database
- Asset Type Support: Handles both images and videos
- Error Handling: Robust error handling with retry logic
- Python 3.7+
- Access to an Immich instance
- Two Immich accounts with API keys (Must be on the same Immich instance)
- Required Python packages (see
requirements.txt)
- Clone this repository:
git clone https://github.com/thomaskeig/immich-share.git
cd immich-share- Install required dependencies:
pip install -r requirements.txt- Configure the script by editing the configuration variables in
main.py:
# Configuration
IMMICH_BASE_URL = "https://your-immich-instance.com"
API_KEY_2 = "your-second-account-api-key"
API_KEY_1 = "your-first-account-api-key"
SYNC_START_DATE = "2025-08-09" # Start date for sync range
SYNC_END_DATE = "2025-08-20" # End date for sync range
SYNC_INTERVAL = 3600 # Sync interval in seconds (1 hour)| Variable | Description | Example |
|---|---|---|
IMMICH_BASE_URL |
Base URL of your Immich instance | "https://photos.example.com" |
API_KEY_1 |
API key for the first Immich account | "your-api-key-here" |
API_KEY_2 |
API key for the second Immich account | "your-api-key-here" |
SYNC_START_DATE |
Start date for syncing assets (YYYY-MM-DD) | "2025-01-01" |
SYNC_END_DATE |
End date for syncing assets (YYYY-MM-DD) | "2025-12-31" |
SYNC_INTERVAL |
Time between sync cycles in seconds | 3600 (1 hour) |
- Log in to your Immich web interface
- Go to Account Settings → API Keys
- Create a new API key
- Copy the generated key and paste it into the configuration
To run the sync continuously with the configured interval:
python main.pyPress Ctrl+C to gracefully stop the continuous sync process.
- Asset Discovery: Fetches all assets from both accounts within the specified date range
- Deletion Detection: Identifies assets that were previously synced but are now missing (indicating deletion)
- Bidirectional Sync:
- Syncs new assets from Account 1 to Account 2
- Syncs new assets from Account 2 to Account 1
- State Tracking: Records all sync operations in a local SQLite database
- Duplicate Prevention: Skips assets that have already been synced
- Deletion Respect: Won't re-sync assets that were intentionally deleted
- Non-Destructive: Never deletes assets, only adds them
- Deletion Awareness: Respects user deletions and won't re-sync deleted items
- State Persistence: Maintains sync state across script restarts
- Duplicate Prevention: Avoids creating duplicate assets
- Only syncs assets within the specified date range
- Requires manual configuration of API keys and date ranges
- Does not sync metadata like albums, tags, or favorites
- Limited to IMAGE and VIDEO asset types
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This script is not officially affiliated with Immich. Use at your own risk and always backup your photos before running sync operations.
For issues and questions:
- Check the troubleshooting section above
- Review the log files for detailed error messages
- Open an issue on GitHub with relevant log excerpts