# restore_code_backup

Source: https://modulify.ai/docs/mcp/backups/restore-code-backup

Rolls the source code of a site back to an earlier code backup and reloads the preview from it, deleting the whole site chat history.

- Title: Restore a site code backup
- Scope: `sites:delete`
- Access: Destructive

It does far more than its name suggests. It deletes the entire site chat history: every message exchanged with the site agent is removed for everyone in the project and cannot be brought back, the agent loses all memory of what was discussed, and any messages queued to run next are thrown away unsent. Any file the agent wrote since that code backup is reverted, and files added since are deleted.

No backup is taken first, unlike `restore_backup`. The tool tells the client never to call it speculatively: it has to tell you plainly that your whole conversation with the agent will be deleted, and get your agreement first. Restoring does not publish, so the live site keeps serving what you published last.

If a generation is running, it refuses with a `409` reading `AI is currently generating. Stop it before restoring this code backup!` unless `cancelActiveJob` is set, which stops that generation mid-flight. It also refuses with a `409` when another code backup is already being restored for the site (`Another code backup is already being restored for this site!`), and when the latest changes of the site are still being saved after about 30 seconds of waiting (`Your latest changes are still being saved. Try restoring again in a moment!`). In both of those cases nothing was changed, so try again in a moment.

Like `restore_backup`, it is refused while the site code is being moved into GitHub, when Modulify has lost access to the GitHub repository that holds the site or that repository was deleted, and when the code lives in the workspace's own GitHub but the workspace is on the Free plan. See [Restore a backup](https://modulify.ai/docs/editor/backups#restore-a-backup).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |
| `codeBackupId` | string | Yes | The code backup to roll back to, from `list_code_backups`. |
| `cancelActiveJob` | boolean | No | True to stop a generation that is running instead of refusing. Set it only when you have agreed to lose that work. |