CLI backup and recovery: from 27 files to a working build

Server-side encryption, an accepted receipt SHA, local recovery and Composer install. The key stays off-server; the plaintext drill is removed.

A craftswoman assembles pieces in a purple tray beside an open capsule and a key.

From a manual pass to a CLI operation

The manual pass already showed that selected E-01 files could be encrypted on the server, restored locally and used to build the application again. I have now run the same narrow scenario through a new Go CLI: capture, verification of the accepted package and local restoration. This is a separate actual automation run, rather than a new name for the manual result.

The set remains explicit: 27 source and configuration files for private Symfony and protected HTTPS. A database, operating system and complete host recovery are outside this run.

Checking state around capture

The CLI checked existing HTTPS before and after reading, under the relevant locks. Files were read twice and compared to avoid accepting an unnoticed change between passes. This is optimistic consistency checking of a selected set, rather than an atomic filesystem snapshot. An operation lock does not stop every possible file writer.

There were no durable server writes or service actions. The application was not stopped for this copy. Such a narrow check fits a defined file set; it cannot be extended to an arbitrary active database as a promise of a consistent backup.

Encryption before leaving the server

The server encrypted content with standard OpenSSL CMS: AES-256-GCM for data and RSA-OAEP with SHA256 for the key. The recipient uses 3072-bit RSA. Only its public certificate was sent to E-01; the recipient private key stayed off the server.

Local capture created a new directory with mode 0700 and two files with mode 0600: encrypted content and a result description. Before restoration, the SHA256 of that description was independently accepted, binding ciphertext and plaintext checksums and the exact permitted source list. A new description cannot simply be trusted because it sits beside the copy.

Encryption to a public certificate does not itself identify the backup author: anyone holding that certificate can encrypt to it. Content protection and a trusted provenance binding are therefore needed together.

Plaintext is checked in memory first

Local decryption kept plaintext in memory. Files were created only after CMS completed successfully and the plaintext checksum matched the accepted value. A failed check must not leave a partially accepted application.

The CLI restored all 27 files with exact bytes, modes and extended attributes. Original numeric uid/gid values remain metadata; the local files belong to the user running the check. Original ownership and NSS access semantics were not applied here.

A repeat using the already occupied destination directory was refused. This protects against overwriting rather than granting permission to replace existing local files. Another run needs a separate new destination.

Building from the recovered lock file

Inside the restored application, Composer installed 32 production packages from the lock file. No prepared vendor directory was copied. Production cache warmup succeeded; the TLS key matched the certificate, and verification against the pinned CA confirmed the hostname and server purpose.

After the build, all 27 original files remained unchanged in bytes, modes and extended attributes. This run therefore checked both decryption and the ability to build an application from the recovered set.

Removing the plaintext tree after the test

The temporary drill tree was removed together with 1735 owned files, including plaintext sources, installed dependencies and cache. The encrypted capture is retained. Cleaning the local drill made no server changes.

An external storage destination has not been selected: no offsite upload, timer or alerts are configured. A separately protected key copy also remains open work. This establishes managed capture and local restoration of a specific set through the CLI; long-term storage and regular execution need their own decision.

Saved CLI results: 27 files, 32 Composer packages, TLS checks and cleanup of the local drill tree. Selected actual result fields, not a rerun or the complete raw output.
  1. PHP Composer on E-01: a separate Symfony build budget
  2. Operations & Security Adopting protected HTTPS with the CLI without a restart
  3. Operations & Security Encrypted E-01 backup and a local recovery drill
  4. Operations & Security Encrypted recovery in private R2: a separate reader and CLI restoration