Once the UI has computed which files are new or changed, these six methods carry out the actual backup. Before starting,Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Pachanga12/Kopia_Desk_Beta_1/llms.txt
Use this file to discover all available pages before exploring further.
journalPeek() checks whether a previous run was interrupted; if so, journalCheck() cleans up any partial writes. The recommended copy pattern is: call planConcurrency() to pick the right parallelism for the destination drive, optionally call backupCopyVersions() to preserve the files that are about to be overwritten, then call backupCopyFiles() to copy everything in parallel. When the operation finishes, logSave() persists the results as a timestamped JSON report.
journalPeek(destRoot)
Inspects the journal directory on the backup drive and reports whether any previous backup run was interrupted, without deleting or modifying any files. The UI calls this on startup so it can warn the user before beginning a new backup run.
The journal directory is located at <destRoot>/KopiaDesk_Backup/.kopia-data/journal/. Journal files use an append-only JSONL format: the first line records all planned destinations; subsequent lines record each file as it is successfully written. If the process is killed before backupCopyFiles() completes, the journal remains on disk with the pending entries still absent. journalPeek() reads these files to count the files that were planned but never completed.
Root path of the backup drive, e.g.
"E:\\". The journal directory is derived from this path.Promise<{ found: number, pendingFiles: number, lastInterruptedAt: string | null }>
Number of journal files found.
0 means no previous backup was interrupted.Total number of files that were planned but not confirmed as written across all found journal files. A value greater than
0 indicates at least one incomplete backup.ISO 8601 timestamp of the most recent interrupted backup’s start time, or
null if none was found or all journals lacked a startedAt field.journalPeek() returns { found: 0, pendingFiles: 0, lastInterruptedAt: null } when the journal directory does not exist—this is the normal state after a clean backup completes, since backupCopyFiles() deletes the journal file on success.journalCheck(destRoot)
Reads all journal files in the backup drive’s journal directory, deletes any partially-written files that were planned but never confirmed, and then removes the journal files themselves. Call this method only after journalPeek() has confirmed that an interrupted backup exists and the user has acknowledged the cleanup.
Root path of the backup drive, e.g.
"E:\\".Promise<{ found: number, filesCleaned: number, lastInterruptedAt: string | null }>
Number of journal files that were processed and deleted.
Number of partially-written backup files that were removed from the backup drive.
ISO 8601 timestamp from the most recent processed journal’s
startedAt field, or null if not available.planConcurrency(driveRoot, avgFileSize)
Queries PowerShell for the physical disk’s MediaType and BusType via Get-Partition and Get-PhysicalDisk, then applies the pickConcurrency heuristic from lib/core.js to suggest the number of parallel copy workers that will give the best throughput on that drive.
Root path of the destination drive, e.g.
"E:\\". The drive letter is extracted with a regex (/^([A-Za-z])/) before being passed to the PowerShell script.Average file size of the files that will be copied, in bytes. Used by
pickConcurrency to decide whether to favour the high or low end of each drive type’s concurrency range. Files smaller than 2 MB are treated as “many small files” and receive higher concurrency.Promise<{ concurrency: number, driveInfo: DriveInfo }>
Recommended number of parallel copy workers based on
pickConcurrency:| Drive type | Small files (< 2 MB avg) | Large files |
|---|---|---|
HDD (mediaType === "HDD") | 2 | 1 |
| SSD or NVMe | 8 | 4 |
| Unknown / USB | 4 | 2 |
Raw drive type data returned by PowerShell. Falls back to
{ mediaType: "Unknown", busType: "Unknown" } if the PowerShell call fails or times out.backupCopyFiles(tasks, options)
Copies an array of files to the backup drive with a bounded parallel worker pool. A journal is started on the destination drive before any files are written and deleted on success; if the process is interrupted mid-copy the journal remains on disk so journalPeek() / journalCheck() can detect and clean up partial writes on the next run.
Array of file copy instructions.
Optional copy behaviour flags.
Promise<{ copied: number, errors: ErrorEntry[], deduped: number }>
Total number of files successfully processed (includes both copied and deduped files).
Files that could not be copied.
Number of files skipped via hard-link deduplication (only non-zero when
options.dedup is true).Progress events
WhilebackupCopyFiles() is running it emits a progress IPC event after each file completes. Subscribe with window.kopiaAPI.onProgress() before calling this method.
| Field | Type | Description |
|---|---|---|
phase | "backup" | Constant identifier for this operation type |
current | number | Number of files completed so far |
total | number | Total number of tasks in this call |
file | string | relativeDest of the file just processed |
percent | number | Math.round((current / total) * 100) |
backupCopyVersions(tasks)
Gzip-compresses existing backup files to a .gz sibling before they are overwritten by the new copy. Call this method before backupCopyFiles() so that the previous version of each changed file is preserved. Files that are listed in the manifest but are no longer physically present on the backup drive are counted as skipped, not errors.
Array of versioning instructions.
srcPath points to the current file on the backup drive (the one about to be overwritten), not the source on the local PC.Promise<{ copied: number, skipped: number, errors: ErrorEntry[] }>
Number of files successfully compressed and written.
Number of entries where
srcPath did not exist on the backup drive. These are not errors; the file simply has no prior version to preserve.Files that existed but could not be compressed. See
ErrorEntry definition under backupCopyFiles.logSave(destRoot, sourceName, report)
Persists an operation report object as a formatted JSON file in the backup drive’s .kopia-data/logs/ directory. The file name encodes both the sanitised source name and a timestamp derived from new Date().toISOString() (colons and dots replaced with hyphens).
Saved path: <destRoot>/KopiaDesk_Backup/.kopia-data/logs/<safeName(sourceName)>_<timestamp>.json
Root of the destination drive, e.g.
"E:\\".Human-readable source folder name. Sanitised through
safeName() (illegal filename characters replaced with _, maximum 120 characters) before use in the file path.Any JSON-serialisable object. Typically includes totals (files copied, errors, duration) assembled by
renderer/app.js after the backup run.Promise<string> — the absolute path to the saved log file.