Syncing
mailarc sync ARCHIVE [--account ID] [--progress] [--keep-awake]sync copies new mail from every enabled, registered account into the archive. It also records:
- changes to flags, labels and folder membership;
- messages that disappeared from the server, which stay in the archive marked as gone.
It never changes anything on the server, and does not even mark messages as read.
Before writing, sync checks the archive's records: the chain of evidence, its seals, and that every recorded message has its place in the packs. It does not re-read every stored message, which on a large archive would take minutes each time; mailarc verify does, so run it now and then (see Archives).
| Option | Effect |
|---|---|
--account ID | Only this account |
--mailbox NAME | Only this folder: the IMAP folder name, or a JMAP mailbox path |
--include-junk, --include-trash | Also archive Spam/Junk and Trash, which are skipped by default |
--dry-run | Count what would be downloaded; nothing is written |
--progress | Show progress while it runs, with how many of the new messages are archived once they are counted (IMAP and POP3) |
--keep-awake | Keep the computer from going to sleep until the sync ends; see Keeping the computer awake |
The first sync of a large mailbox takes a while; how long depends mostly on your internet connection and your provider. Later syncs fetch only what changed.
Keeping the computer awake
A long first sync stops when the computer goes to sleep. With --keep-awake, sync asks the system not to sleep while it runs, including the search index update afterwards. The request ends with the sync, even if it crashes.
- It uses the system's own tool:
caffeinateon macOS,systemd-inhibiton Linux, and Windows PowerShell on Windows. - Only sleep from being idle is held off. The display may still turn off, and closing a laptop's lid or choosing Sleep still sleeps the computer.
- It does not wake a sleeping computer for a scheduled sync.
- If the system refuses, for example on Linux without a login session, sync says so and runs anyway. With
--json, the result'skept_awakeisfalse.
Stopping and resuming
Press Ctrl-C, or stop the scheduled job: sync finishes at the next safe point and exits with code 130. Everything committed so far stays, and the next sync continues. A crash or power loss loses nothing committed either; the next sync repairs the interrupted state first.
Network errors and server throttling are retried automatically, up to three times per account or folder with growing pauses. A folder that still fails is reported, and the others continue.
Full checks
Servers with change tracking let later syncs ask only for what changed. On a schedule, every 7 days by default, sync also compares the complete list of messages, to catch deletions the change tracking missed. Change the interval with:
mailarc account set-reconcile-interval ARCHIVE ID --days 14 [--mailbox NAME]POP3 compares the whole maildrop every time.
On a schedule
The desktop app can set this up for you; see Sync automatically. This section is for the command line.
Schedule the same command you run by hand, with absolute paths. Hourly is a good default. It uses the same account settings file as the desktop app.
mailarc sync /Users/me/Mail/Archive.mailarc --json- Only one writer at a time. A run that starts while another sync, import or seal is running exits at once with
archive_lockedand changes nothing. Treat it as a skipped run. - Keychain access.
- macOS: use a LaunchAgent, which runs in your login session. Install a stable copy of
mailarc(macOS ties keychain permission to the program). Run the exact command once in Terminal and choose Always Allow when asked. - Linux: use a systemd user timer. Your keyring must be running and unlocked in your session.
- Windows: use Task Scheduler with Run only when user is logged on, so the sync can read Credential Manager. Run whether user is logged on or not cannot read it. Ending the task stops the sync at once, not at a safe point; the next run repairs and continues.
- macOS: use a LaunchAgent, which runs in your login session. Install a stable copy of
- Logs. Send output to private files; reports name your accounts and folders.
- Daily seal. If some days have no sync, also schedule
mailarc seal ARCHIVEonce a day.
macOS LaunchAgent (~/Library/LaunchAgents/com.example.mailarc-sync.plist; use absolute paths):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>com.example.mailarc-sync</string>
<key>ProgramArguments</key>
<array>
<string>/Users/me/.cargo/bin/mailarc</string>
<string>sync</string>
<string>/Users/me/Mail/Archive.mailarc</string>
<string>--json</string>
</array>
<key>StartInterval</key><integer>3600</integer>
<key>ExitTimeOut</key><integer>300</integer>
<key>Umask</key><integer>63</integer>
<key>StandardOutPath</key><string>/Users/me/Library/Logs/mailarc/sync.json</string>
<key>StandardErrorPath</key><string>/Users/me/Library/Logs/mailarc/sync.err</string>
</dict>
</plist>Create the log folder first (mkdir -p -m 700 ~/Library/Logs/mailarc), then load it with launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.example.mailarc-sync.plist.
systemd user units (~/.config/systemd/user/), enabled with systemctl --user enable --now mailarc-sync.timer:
# mailarc-sync.service
[Unit]
Description=mailarc sync
[Service]
Type=oneshot
UMask=0077
ExecStart=%h/.cargo/bin/mailarc sync %h/Mail/Archive.mailarc --json
TimeoutStopSec=300
SuccessExitStatus=130
# mailarc-sync.timer
[Unit]
Description=Hourly mailarc sync
[Timer]
OnCalendar=hourly
RandomizedDelaySec=5min
Persistent=true
[Install]
WantedBy=timers.targetSee Troubleshooting for what each exit code means for a scheduled run.