Skip to main content

Module backup

Module backup 

Source
Expand description

Snapshots of the library metadata.json in backup/, kept the way Eagle keeps them, and recovery from them when metadata.json is damaged.

Eagle copies metadata.json to backup/backup-YYYY-MM-DD HH.mm.ss.SSS.json (local time) when the library changed and every 30 minutes. It skips the copy when the newest backup has the same size, refuses to back up a file that doesn’t parse or lacks applicationVersion, and keeps at most 100 backups. On open, a metadata.json that fails to parse is replaced by the newest backup that parses and has a modificationTime; the damaged file is kept as backup/metadata.json.damaged-<ms>.

Eagle also keeps one more copy outside the library, in its app data: eagle-backup/<hash>.json, where <hash> is the 32-bit FNV-1a hash of the library path (no trailing slash) over its UTF-16 code units, as 8 lowercase hex digits (app_data_backup_name). It replaces that copy whenever it writes a new backup into an existing backup/ list (not for the very first one); falcon replaces it with every new backup. Nothing is written for a library whose folder is gone, so a backup never recreates a moved or deleted library.

Constants§

MAX_BACKUP_COUNT
Most backups Eagle keeps; older ones are deleted.

Functions§

app_data_backup_name
The name of the app-data copy of the library at root: <fnv1a-32 of the path>.json, as Eagle names it.
backup_library
Library::backup_metadata for the library at root, without opening it. It only reads metadata.json and writes into backup/, so the app runs it on a background thread while the library stays in use: a metadata.json caught mid-write doesn’t parse and is skipped.
backup_library_with
backup_library, also replacing the library’s copy in app_backups (the app’s eagle-backup folder, created if needed) whenever a new backup is written. A failure there is ignored, as Eagle ignores it.
backup_name
The file name Eagle gives a backup taken at time (local time), e.g. backup-2026-10-26 02.15.25.310.json.