bug: standalone restore script not uploaded to remote (silent — result ignored) #226
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
On suite.dev, the last backup uploaded to the remote (SFTP/"FTP") but the standalone restore script was not present on the remote. The archive uploaded fine; the restore script did not.
Code finding (
BackupEngine.php)In the remote-upload loop, after the archive uploads successfully, the standalone restore script is uploaded — but the result is discarded and nothing is logged:
(
src/Engine/BackupEngine.php~306–308)So if this second
upload()fails — e.g. the uploader closed its connection after the first file, or a per-file error — the restore script is silently missing: no warning, no$uploadFailed, the backup is still recordedcomplete.Two related points:
include_mokorestore = '1'(wrap) embeds the restore script inside the archive (the uploaded archive IS the-mokorestorezip), so there is no separate file.include_mokorestore = 'standalone'writes$restoreScriptPathand uploads it separately. If the suite.dev profile is in wrap mode, the script should be inside the archive — worth confirming which mode the profile uses.upload()reuses the same$uploaderinstance. Some uploaders open/close a connection perupload()call; a second call may silently no-op or fail depending on implementation (SFTP/S3/GDrive each differ).Proposed fix
$this->log()it and set$uploadFailed = true(→warningstatus) if it fails, so it's never silent.upload()on the same instance (re-open connection if needed).Still to confirm (needs suite.dev)
include_mokorestoremode (wrap vs standalone).Couldn't pull the suite.dev logs/files directly from here (production shell access is gated); happy to walk through them or take a look if access is approved.
Branch created:
feature/226-bug-standalone-restore-script-not-uploadRoot cause found and fixed in #228 (merged to
dev).The restore script was never uploaded because it was never generated —
MokoRestore::generateStandaloneScript()had astr_replace()call atMokoRestore.php:181(the "Backup Archive" pre-check rewrite) that was missing its third$phpsubject argument. On PHP 8 that is a fatalArgumentCountErrorat runtime, so every standalone-mode backup died at the "Generating standalone restore.php…" step:The archive itself still finalized and uploaded, which is why the backup looked successful while
restore.phpsilently went missing on the remote.Two-part fix now on
dev:restore.php.warninginstead of passing silently.Will confirm on suite.dev after the next
devbuild, then close.✅ Verified fixed on suite.dev (deployed
02.58.09-dev, profile 1 = standalone MokoRestore + SFTP remote).restore.php— confirming thegenerateStandalone()FATAL meant the script was never produced.[OK] Backup complete … (123.74 MB)with nostr_replaceerror, and the remote now listsrestore.phpalongside the new archive.Root cause (#228) + non-silent upload (#227) both confirmed working end to end. Closing.