From 3cd7c4af29014e78de484f99288a8fcdc716acae Mon Sep 17 00:00:00 2001 From: Saadanjum0 <160885369+Saadanjum0@users.noreply.github.com> Date: Fri, 2 Oct 2026 12:59:23 +0500 Subject: [PATCH] fix: preserve dangling symlinks when copying backup data on macOS cp -rp followed symlinks on BSD cp (macOS) because lowercase -r implies -L for historical compatibility, so a dangling certificate symlink under /captain/data raised ENOENT and aborted the whole backup copy. GNU cp (Linux) never followed symlinks here either way, so this only reproduced in local macOS dev/test runs, not CI. Switch to -RPp: -R is the portable recursive flag and -P makes the no-dereference behavior explicit on both cp implementations. --- src/user/system/BackupManager.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/user/system/BackupManager.ts b/src/user/system/BackupManager.ts index 647c66f8..e86fb422 100644 --- a/src/user/system/BackupManager.ts +++ b/src/user/system/BackupManager.ts @@ -43,9 +43,14 @@ export function copyCaptainDataForBackup( .then( () => new Promise((resolve, reject) => { + // -R (not -r) with -P keeps dangling/symlinked certs + // as symlinks on BSD cp (macOS) too. BSD's lowercase + // -r implies following symlinks for compatibility, + // which throws ENOENT on a broken link; GNU cp (Linux) + // never followed them either way. execFile( 'cp', - ['-rp', `${sourceDirectory}/.`, destinationDirectory], + ['-RPp', `${sourceDirectory}/.`, destinationDirectory], (error) => { if (error) { reject(error)