Automate Syncs¶
Set up automatic daily backups of your Strava activities.
Using cron¶
The simplest way to automate syncs is with cron.
Step 1: Find Your Installation¶
Step 2: Edit Crontab¶
Step 3: Add Sync Job¶
Add a line to sync daily at 2 AM:
Using uv
If you installed with uv:
Options for Cron¶
--quiet- Only output errors--lean-update- Skip sync if already up to date
# Lean sync - skip if no new activities
0 2 * * * cd /path/to/data && mykrok sync --quiet --lean-update
Using systemd¶
For more control, use a systemd timer.
Step 1: Create Service File¶
Create /etc/systemd/user/mykrok-sync.service:
[Unit]
Description=MyKrok Strava Sync
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
WorkingDirectory=/path/to/your/data
ExecStart=/home/user/.local/bin/mykrok sync --quiet
Step 2: Create Timer File¶
Create /etc/systemd/user/mykrok-sync.timer:
[Unit]
Description=Daily MyKrok sync
[Timer]
OnCalendar=*-*-* 02:00:00
Persistent=true
[Install]
WantedBy=timers.target
Step 3: Enable Timer¶
systemctl --user daemon-reload
systemctl --user enable mykrok-sync.timer
systemctl --user start mykrok-sync.timer
Step 4: Check Status¶
Handling Errors¶
Logging¶
Redirect output to a log file:
Email Notifications¶
Cron sends email on errors by default. Configure with:
Rate Limits¶
If you hit Strava's rate limit:
- The sync pauses automatically
- It resumes when the limit resets
- No action needed
Regenerating the Browser¶
To keep your map browser up to date, add a second job:
# Sync at 2 AM
0 2 * * * cd /path/to/data && mykrok sync --quiet
# Regenerate browser at 3 AM
0 3 * * * cd /path/to/data && mykrok create-browser
Git/DataLad Integration¶
If using DataLad, commit changes after sync: