Skip to content

restore: stop writing *.backup.<epoch> copies into the project - #21

Merged
mlaurense merged 2 commits into
mainfrom
bugfix/restore-config-backups-out-of-root
Nov 10, 2026
Merged

mlaurense merged 2 commits into
mainfrom
bugfix/restore-config-backups-out-of-root

Conversation

@marcepartment

Copy link
Copy Markdown
Collaborator

Problem

Before overwriting a project's configuration files with the archived copies, restoreConfigurations (utils/backup.sh) saved each file it was about to change as <file>.backup.<epoch> next to the original. roll pull runs roll restore, so every pull whose .env.roll, app/etc/env.php, auth.json, composer.json or composer.lock differed from the build server's added another copy to the project root and app/etc:

  • junk that accumulates (several .env.roll.backup.* per shop, 1.3 MB per composer.lock.backup.*);
  • credentials in the env.php and auth.json copies;
  • usually hidden by the project's .gitignore, so it piles up unnoticed, and where it is not ignored a git add -A would commit it.

Fix

The restore now overwrites without keeping a copy. Nobody used them: .env.roll and composer.* are tracked in the shops checked, so git checkout -- <file> brings a local version back, and after a pull the archived env.php and auth.json are the ones wanted.

roll config set/version/fix-pins still write .env.roll.backup.<date>. Those only happen on an explicit command that prints the path, so they are left as they are.

Verification

Calling restoreConfigurations directly against a fake backup whose .env.roll, env.php and auth.json differ from the project's, with main as the control:

*.backup.* files untracked in git status restored contents
main 3 3 archived copies
this branch 0 0 archived copies (identical)
  • ShellCheck is clean and .github/scripts/smoke.sh bash32 passes.
  • docs/backup-restore.md explains the overwrite and how to list the old leftovers. The CHANGELOG has a "Fixed" entry.

🤖 Generated with Claude Code

restoreConfigurations saved every file it was about to overwrite as
`<file>.backup.<epoch>` next to it, so each `roll pull` whose archived
.env.roll, env.php, auth.json or composer.lock differed from the local copy
left another file in the project root and app/etc: credentials included,
1.3 MB per composer.lock, and usually hidden by the project's .gitignore.

Nobody used them. .env.roll and composer.* are tracked and come back with
`git checkout`, and after a pull the archived env.php and auth.json are the
ones wanted. The restore now overwrites without keeping a copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The encrypted restore truncates the existing configuration before decryption succeeds, so a decryption failure can leave it empty or partial with no recovery copy.

1 open issue
What changed in this PR

This PR stops configuration restores from leaving timestamped backup copies in project directories, reducing clutter and leftover credential files during roll restore and roll pull.

Changes:

  • Removes the pre-overwrite configuration backup step.
  • Documents overwrite behavior, preservation advice, and how to locate old copies.
  • Adds a changelog entry describing the change.
File Description
utils/​backup.sh Removes creation of configuration recovery copies before overwriting.
docs/​backup-restore.md Explains overwrite behavior and locating old backup files.
CHANGELOG.md Records the removal of timestamped restore backups.

Review effort: Balanced

Comment thread utils/backup.sh
fi
fi

# The existing file is overwritten without keeping a copy. Restores used to save it as
`gpg --decrypt ... > "$target_path"` truncated the target before decryption
started, so a wrong passphrase or a damaged archive left an empty env.php
or auth.json. With the pre-restore copies gone that was unrecoverable.
decryptConfigInto decrypts into a mktemp file next to the target and writes
the target only on success (cat, so its owner and mode stay), for both the
structured and the legacy backup layout.

Raised by Copilot on #21.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mlaurense
mlaurense merged commit 74e74a2 into main Nov 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants