AI coding agent backups need a stronger success condition than a green sync job. A useful design preserves several historical recovery points outside the agent's deletion authority, then proves one can rebuild a working project in isolation. This guide gives you the state inventory, permission boundary, restore contract, and drill needed to produce that proof.
Reading time: about 11 minutes | Length: about 2,160 words
TL;DR
- Sync converges on the latest state, so it can propagate deletion, corruption, and unwanted rewrites. Recovery needs version history and a separate failure domain.
- Treat Git history, uncommitted work, agent configuration, secrets, local data, and external systems as different recovery layers.
- Separate the coding identity, append-only backup identity, and temporary restore identity. The agent should lack authority to shorten retention or destroy old recovery points.
- A backup becomes trustworthy after an isolated restore passes integrity, build, test, startup, and human acceptance checks.
The Model Safety Result Is the Starting Signal
OpenAI's GPT-5.6 System Card, published July 9, 2026, includes an evaluation for accidental data-destructive actions. It tests whether a model can finish a task without overwriting user changes and data that were adversarially placed in the environment.
GPT-5.6 Sol scored 0.83 on overwrite avoidance, compared with 0.88 for GPT-5.5. Both scored 0.44 on the combined avoidance-and-correctness measure. OpenAI describes Sol as remaining strong, while also reporting that internal agentic-coding simulations found a greater tendency than GPT-5.5 to act beyond user intent. Absolute rates in that simulation remained low.
These numbers are evaluation results, not production loss rates. Their architectural meaning is narrower and more useful: model training, confirmation policy, and supervision reduce the probability of destructive behavior, while a residual risk remains. Recovery is a separate downstream property.
A stronger model may avoid more conflicts. It still cannot prove that yesterday's work, an untracked migration script, a local Agent instruction, and a working database snapshot can all be recovered after its credentials or judgment fail.
Sync Converges; Backup Preserves Options
Synchronization optimizes convergence. When a file changes on one side, the other side receives the change quickly. That behavior is valuable for collaboration and device continuity.
The same behavior copies a bad current state. Deletion, encryption, truncation, an unwanted git reset, or a broken configuration can reach the synchronized destination before anyone notices.
CISA's StopRansomware Guide makes this boundary explicit: automated cloud backup or sync can propagate damaged files and overwrite unaffected remote data. CISA recommends offline, encrypted backups and regular tests of both availability and integrity. Ransomware is the guide's threat model; a coding agent with valid file and cloud credentials creates the same architectural condition: the actor and the recovery copy can share one blast radius.
Version history improves the situation, but the word versioned is still incomplete. Ask four questions:
- Can the agent delete or expire every old version?
- Does history cover every state needed to resume work?
- Can the archive be decrypted and extracted with credentials available during an incident?
- Has a recovered copy passed the checks that define a working project?
This creates an evidence ladder:
| Evidence level | What it proves | What remains unknown |
|---|---|---|
| Job started or completed | Automation ran | Whether a usable recovery point exists |
| Recovery point is listed | Metadata and an archive entry exist | Whether stored bytes are intact |
| Repository and data verify | Archive structure and content pass integrity checks | Whether the project works after extraction |
| Isolated restore passes acceptance | The workspace can resume from that point | Whether future drills and new dependencies will still pass |
Operational dashboards often stop at level one. Restore certainty starts at level four.
Write the Restore Contract Before Choosing a Tool
A restore contract translates safe backup into testable statements. It should be short enough to review and specific enough to execute.
Define the recovery targets
NIST SP 800-34 defines two useful measures:
- Recovery Point Objective (RPO): the point in time to which data must be recovered. For a coding workspace, this is the maximum acceptable age of the newest usable recovery point.
- Recovery Time Objective (RTO): the maximum time the resource may remain unavailable before impact becomes unacceptable. Measure it from the start of recovery until the restored project passes acceptance, rather than stopping when files finish downloading.
A team making a few commits per week may accept a daily RPO. A migration or release window may require hourly or event-triggered points. The impact and change rate choose the numbers.
Define what a working recovery means
A practical contract can look like this:
scope:
git_history: required
uncommitted_and_untracked_work: required
agent_instructions_and_tools: required
local_database: latest_consistent_snapshot
plaintext_secrets: forbidden
objectives:
rpo: 2h
rto: 45m
acceptance:
- expected commit and branches exist
- manifest and critical-file hashes match
- dependency lockfiles recreate the environment
- lint, build, and unit tests pass
- application starts in an isolated environment
- one controlled smoke test passes
- no plaintext credential appears in the archive
The values are examples. The structure is the reusable part: scope, objectives, exclusions, and executable acceptance.
Back Up the Workspace as Several State Layers
A remote Git repository is essential, yet it represents only one recovery layer.
| Layer | Examples | Suitable recovery mechanism |
|---|---|---|
| Published Git state | commits, branches, tags, remote refs | protected remote plus independent mirror |
| Local work in progress | uncommitted changes, untracked files, stashes, local branches, worktrees | versioned filesystem snapshot with an explicit include list |
| Agent and tool state | project instructions, skills, plugins, MCP configuration, IDE or CLI settings | versioned configuration archive, excluding volatile logs and caches |
| Rebuildable environment | dependencies, toolchains, containers, generated caches | lockfiles, declarative images, build scripts; back up only expensive or irreplaceable artifacts |
| Stateful development data | local databases, volumes, fixtures, test objects | application-consistent export or snapshot |
| External systems | issues, pull requests, CI settings, cloud resources, queues | provider-specific export, API backup, or infrastructure-as-code |
| Secrets and trust | API keys, SSH keys, recovery keys, vault policy | separately governed secret store and tested recovery procedure |
GitHub's repository backup guidance recommends a mirror clone for revision history. Git LFS objects require a separate fetch. GitHub also warns that migration archives omit some data and have no supported documented restoration path.
Local Git recovery has limits too. Reflogs record recent reference changes, but Git documents expiration defaults, and git gc may eventually remove unreachable objects. Reflog is an excellent first response to a bad rebase or reset. It is a local grace period rather than an independent disaster-recovery copy.
Secrets need the opposite treatment from source files. Archive secret references, ownership, rotation instructions, and recovery procedures. Keep plaintext credentials in a separately controlled system. A backup that restores the project by leaking every production key creates a second incident.
This layered view also separates this problem from AI Agent sandbox persistence. Sandbox snapshots answer what survives a compute lifecycle. Backup architecture answers what survives loss or compromise of that lifecycle and its controlling identity.
Use Three Identities and More Than One Failure Domain
The most important control is authority separation. A copy reachable with the same credential that can delete the source is a convenient replica inside the same failure domain.
Use three roles:
| Identity | Needed authority | Authority to withhold |
|---|---|---|
| Coding agent | task-scoped read and write in the workspace | backup retention, repository compaction, old-snapshot deletion |
| Backup writer | read the documented include set and append a recovery point | source-code modification, retention reduction, permanent deletion |
| Restore operator | temporarily read selected recovery points and write to an isolated target | routine coding access, retention management, production overwrite by default |
Test the denied paths. The coding identity should fail when it tries to delete an old recovery point. The backup identity should fail when it tries to modify the source. The restore identity should fail when it tries to change retention.
The familiar 3-2-1 rule is a useful inventory heuristic: three copies, two storage types, and one offsite copy. It describes distribution, not recoverability. One offline or immutable copy and a zero-error restore verification strengthen the design, but a slogan cannot replace a drill.
BorgBackup provides a concrete implementation example. Its append-only mode prevents overwriting or permanently deleting committed segment data and keeps a transaction log. Borg documents separate SSH keys: one forced to borg serve --append-only for the client, and another with normal access for backup management.
The boundary matters. borg delete and borg prune can still change the visible manifest in append-only mode. Recovery remains possible because committed segment data cannot be compacted away under that restricted path. Management authority, compaction, repository-level filesystem access, and recovery keys must stay outside the coding agent's credentials.
The earlier pre-install trust boundary limits what code may execute. The backup boundary assumes an allowed component or agent can still make a destructive mistake and limits how far that mistake can travel.
Test the Restore, Not the Backup Job
Run the drill in a fresh directory, temporary user, container, or disposable VM. Reusing the live home directory introduces hidden dependencies and turns a test into a possible overwrite event.
A Borg-based evidence sequence illustrates the distinction:
# Level 2: confirm the intended recovery point is discoverable
borg list "$BORG_REPO"
# Level 3: verify repository, archive, and stored data integrity
borg check --verify-data "$BORG_REPO"
# Preview extraction without writing files
borg extract --dry-run "$BORG_REPO"::workspace-2026-07-28
# Level 4 begins in an empty, isolated target
restore_dir="$(mktemp -d)"
cd "$restore_dir"
borg extract "$BORG_REPO"::workspace-2026-07-28
borg check --verify-data reads, decrypts, decompresses, and cryptographically verifies archive data. That is strong storage evidence. It still cannot tell whether the restored dependency graph builds, a local database opens consistently, an Agent configuration parses, or a required plugin remains compatible.
Continue with project-specific acceptance:
git -C project fsck --full
git -C project status --short
cd project
./scripts/bootstrap-clean-room.sh
./scripts/lint.sh
./scripts/test.sh
./scripts/smoke-test.sh
These script names are placeholders for your repository's deterministic setup and validation commands. Record the recovery-point timestamp, chosen archive, actual RPO, elapsed end-to-end RTO, command outputs, missing assets, and the final human decision.
Rotate scenarios instead of restoring only the newest happy path:
- an Agent overwrites or truncates files;
- a worktree or unpushed branch disappears;
- local Git objects become corrupt;
- synchronized storage propagates deletion;
- the coding credential is compromised;
- the backup repository becomes unavailable;
- local database state requires a consistent restore;
- an external service has advanced beyond the recovered workspace.
Pick recovery points randomly within the retention window. A drill that always selects the newest archive tests a narrower system than the one you expect to rely on.
A Minimum Production Checklist
Before allowing a coding agent to make broad workspace changes:
- Inventory every state layer and label it required, rebuildable, external, or forbidden.
- Set an impact-based RPO and an end-to-end RTO.
- Keep historical versions rather than one converged mirror.
- Put at least one recovery copy outside the coding identity's deletion and retention authority.
- Protect encryption keys and test their recovery separately.
- Run archive integrity checks on a schedule.
- Restore into an isolated environment and execute build, test, startup, and smoke checks.
- Store drill evidence and alert on overdue or failed drills.
- Repeat after toolchain upgrades, backup-policy changes, new Agent integrations, and storage migrations.
The first drill usually finds the real design: a missing LFS object, an untracked configuration, a plaintext token in an archive, an undocumented package registry, or a test that only passes with the developer's old cache. Each finding converts implicit state into an explicit contract.
FAQ
What is the difference between backup and sync?
Sync keeps locations aligned with the latest state. Backup keeps historical recovery points under a retention policy. A versioned sync service can contribute to backup, provided old versions survive source-side deletion and a restore test proves they are usable.
Is GitHub enough backup for an AI coding workspace?
GitHub can preserve pushed Git history, and a mirror clone can create an independent copy. It does not automatically preserve uncommitted changes, untracked files, local worktrees, local databases, every GitHub feature, Agent configuration, or external systems. Map each layer separately.
Does borg check --verify-data prove a restore will work?
It proves strong repository and content integrity. Application usability requires extraction into isolation followed by environment recreation, build, test, startup, and relevant human checks.
How often should restore drills run?
Choose cadence from change rate and impact. Run more often during migrations and release periods, and trigger an additional drill after backup-tool, credential, retention, storage, or Agent configuration changes. The contract should define a maximum age for the latest successful drill.
How should secrets be handled?
Exclude plaintext secrets from workspace archives. Back up references, ownership, rotation procedures, and the separately governed secret store according to its own recovery process. Test that restored applications can rebind credentials without embedding them in the backup.
References and Next Action
Primary references, verified July 28, 2026:
- OpenAI GPT-5.6 System Card
- CISA StopRansomware Guide
- NIST SP 800-34 Rev. 1
- BorgBackup:
borg check - BorgBackup: append-only mode
- BorgBackup: restricted repository server
- GitHub: Backing up a repository
- Git: reflog documentation
Start with one project this week. Write its restore contract, create a recovery point, restore it into an empty environment, and keep the failed checks. Those failures are the state your current backup design did not know it owned.