gitbutlerapp/gitbutler · warning

Attempting to restore backup

Error message

Attempting to restore backup

What it means

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.

Solutions

  1. Do nothing if the log says 'Backup restored successfully' — your previous install is intact; investigate why the new binary failed validation.
  2. If the restore itself failed, restore manually from but.backup.* in the bin directory (mv but.backup.<ts> but).
  3. Re-run the installer with a verified-good download to attempt the upgrade again.
  4. Keep the backup file until the new version is confirmed working.
Defensive patterns

Strategy: fallback

Validate before calling

# Confirm a backup exists and runs before attempting an upgrade
import os, subprocess, glob
backups = glob.glob(os.path.expanduser('~/.local/bin/but.backup.*'))
assert backups, 'no backup found'
subprocess.run([backups[-1], '--version'], check=True)

Try / catch

// Fall back to the backup only if it exists and validates
if let Some(backup) = but_backup {
    fs::rename(&backup, &install_bin_path)?;
    if validate_installed_binary(&install_bin_path) { bail!("previous install restored"); }
    bail!("restore also failed; binary remains at {}", backup.display());
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/2f91823cca7a4f8e. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-installer/src/install_linux.rs:112

            .map(|c| format!(" channel {}", c.display_name()))
            .unwrap_or_default(),
        install_bin_path.to_string_lossy(),
    ));

    // NOTE: Must copy rather than rename. Rename assumes source and dest are on the same mount
    // point, but /tmp on Linux systems is very often an in-memory file system (tmpfs) and thus on
    // a different mount point than persistent files
    fs::copy(but_path, &install_bin_path)?;

    let mut perms = fs::metadata(&install_bin_path)?.permissions();
    perms.set_mode(0o755);
    fs::set_permissions(&install_bin_path, perms)?;

    if !validate_installed_binary(&install_bin_path) {
        warn("Final installation verification failed");

        if let Some(but_backup) = but_backup {
            warn("Attempting to restore backup");
            fs::rename(&but_backup, &install_bin_path)?;

            if validate_installed_binary(&install_bin_path) {
                info("Backup restored successfully, exiting ...");
                bail!("Installation failed but your previous installation was restored");
            } else {
                bail!(
                    "Installation failed and backup restoration also failed - 'but' command may not work"
                );
            }
        } else {
            bail!("Installation failed and no backup available to restore");
        }
    } else if let Some(but_backup) = but_backup {
        info(&format!(
            "Removing backup at {}",
            but_backup.to_string_lossy()
        ));

View on GitHub (pinned to 58e5313667)