{"record":{"id":"2f91823cca7a4f8e","repo":"gitbutlerapp/gitbutler","slug":"attempting-to-restore-backup","errorCode":null,"errorMessage":"Attempting to restore backup","messagePattern":"Attempting to restore backup","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/but-installer/src/install_linux.rs","lineNumber":112,"sourceCode":"            .map(|c| format!(\" channel {}\", c.display_name()))\n            .unwrap_or_default(),\n        install_bin_path.to_string_lossy(),\n    ));\n\n    // NOTE: Must copy rather than rename. Rename assumes source and dest are on the same mount\n    // point, but /tmp on Linux systems is very often an in-memory file system (tmpfs) and thus on\n    // a different mount point than persistent files\n    fs::copy(but_path, &install_bin_path)?;\n\n    let mut perms = fs::metadata(&install_bin_path)?.permissions();\n    perms.set_mode(0o755);\n    fs::set_permissions(&install_bin_path, perms)?;\n\n    if !validate_installed_binary(&install_bin_path) {\n        warn(\"Final installation verification failed\");\n\n        if let Some(but_backup) = but_backup {\n            warn(\"Attempting to restore backup\");\n            fs::rename(&but_backup, &install_bin_path)?;\n\n            if validate_installed_binary(&install_bin_path) {\n                info(\"Backup restored successfully, exiting ...\");\n                bail!(\"Installation failed but your previous installation was restored\");\n            } else {\n                bail!(\n                    \"Installation failed and backup restoration also failed - 'but' command may not work\"\n                );\n            }\n        } else {\n            bail!(\"Installation failed and no backup available to restore\");\n        }\n    } else if let Some(but_backup) = but_backup {\n        info(&format!(\n            \"Removing backup at {}\",\n            but_backup.to_string_lossy()\n        ));","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-installer/src/install_linux.rs#L94-L130","documentation":"Follow-up warning after 'Final installation verification failed': the installer found a backup of the previous binary and warns 'Attempting to restore backup', then renames it over the failed install and validates again. Depending on the result it reports either a successful restore (and bails saying the old install is back) or a failed restore path.","triggerScenarios":"Raised in install_app (download_and_install_app) when validation of the just-installed binary failed AND but_backup was Some — i.e. a previous installation existed and was backed up before the install attempt.","commonSituations":"Normal downgrade/recovery flow after a bad install: corrupted new binary, incompatible architecture, or failed validation with an older working version previously backed up in the same bin directory.","solutions":["Do nothing if the log says 'Backup restored successfully' — your previous install is intact; investigate why the new binary failed validation.","If the restore itself failed, restore manually from but.backup.* in the bin directory (mv but.backup.<ts> but).","Re-run the installer with a verified-good download to attempt the upgrade again.","Keep the backup file until the new version is confirmed working."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# Confirm a backup exists and runs before attempting an upgrade\nimport os, subprocess, glob\nbackups = glob.glob(os.path.expanduser('~/.local/bin/but.backup.*'))\nassert backups, 'no backup found'\nsubprocess.run([backups[-1], '--version'], check=True)","typeGuard":null,"tryCatchPattern":"// Fall back to the backup only if it exists and validates\nif let Some(backup) = but_backup {\n    fs::rename(&backup, &install_bin_path)?;\n    if validate_installed_binary(&install_bin_path) { bail!(\"previous install restored\"); }\n    bail!(\"restore also failed; binary remains at {}\", backup.display());\n}","preventionTips":["Keep but.backup.* until the new install is verified working","Test the backup binary (--version) before deleting old backups","Upgrade during a window where a broken CLI is tolerable; keep the previous release artifact handy"],"tags":["linux","installer","backup","rollback"],"backgroundTag":"file-not-found","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}