> ## Documentation Index
> Fetch the complete documentation index at: https://developer.upsun.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Restore an environment from a backup

> See how to restore an environment from a previous state.

export const VariableBlock = ({name}) => {
  return <var spellCheck={false} title={`Replace '${name}' with your own data`}>{name}</var>;
};

export const SuccessIcon = () => <svg width="24px" height="24px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true" style={{
  display: 'inline',
  verticalAlign: 'middle'
}}>
    <title id="success-icon">Success</title>
    <path d="M10,0C4.5,0,0,4.5,0,10s4.5,10,10,10s10-4.5,10-10S15.5,0,10,0z M3.7,10.7c-0.4-0.4-0.4-1,0-1.4 c0.4-0.4,1-0.4,1.4,0L8,12.2l6.9-6.9c0.4-0.4,1-0.4,1.4,0c0.4,0.4,0.4,1,0,1.4l-7.6,7.6c-0.4,0.4-1,0.4-1.4,0L3.7,10.7z" fill="#23B7B7"></path>
  </svg>;

export const MoreIcon = () => <svg width="24px" height="24px" style={{
  display: 'inline',
  verticalAlign: 'middle'
}}>
    <title id="more-icon">More</title>
    <path d="M12 6.5C12.8284 6.5 13.5 5.82843 13.5 5C13.5 4.17157 12.8284 3.5 12 3.5C11.1716 3.5 10.5 4.17157 10.5 5C10.5 5.82843 11.1716 6.5 12 6.5Z" fill="current"></path>
    <path d="M12 13.5C12.8284 13.5 13.5 12.8284 13.5 12C13.5 11.1716 12.8284 10.5 12 10.5C11.1716 10.5 10.5 11.1716 10.5 12C10.5 12.8284 11.1716 13.5 12 13.5Z" fill="current"></path>
    <path d="M12 20.5C12.8284 20.5 13.5 19.8284 13.5 19C13.5 18.1716 12.8284 17.5 12 17.5C11.1716 17.5 10.5 18.1716 10.5 19C10.5 19.8284 11.1716 20.5 12 20.5Z" fill="current"></path>
  </svg>;

Once you have [backups of your environment](/docs/environments/backup), you can restore data from a previous point.

To restore an environment, you need an [Admin role for that environment type](/docs/administration/users).

## 1. List available backups

To restore an environment, first select one of the available backups:

<Tabs>
  <Tab title="Using the CLI">
    Run the following command:

    ```bash theme={null}
    upsun backups
    ```

    You get a response similar to the following:

    ```bash theme={null}
    Backups on the project My Project (1234567abcdef), environment main (type: production):
    +---------------------------+----------------------------+------------+
    | Created                   | Backup ID                  | Restorable |
    +---------------------------+----------------------------+------------+
    | 2026-08-15T09:48:58+01:00 | 5ouvtgo4v75axijww7sqnftste | true       |
    | 2026-07-09T14:17:17+01:00 | 7jks7dru5xpx5p5id5wtypur2y | true       |
    | 2026-06-22T18:33:29+01:00 | f3jbyxlhtmalco67fmfoxs7n4m | true       |
    +---------------------------+----------------------------+------------+
    ```

    Select one of the backups marked as **Restorable** and copy its **Backup ID**.
  </Tab>

  <Tab title="In the Console">
    1. Navigate to the environment where you want to see backups.
    2. Click **Backups**.

    Select one of the backups marked as having completed successfully <SuccessIcon />.
  </Tab>
</Tabs>

## 2. Restore from a backup

To restore the backup you've selected, follow these steps:

<Tabs>
  <Tab title="Using the CLI">
    1. Run the following command:

       ```bash theme={null}
       upsun backup:restore <BACKUP_ID>
       ```

    2. Press `enter` to agree with the consequences and continue.
  </Tab>

  <Tab title="In the Console">
    1. Next to the backup you've selected, click **More** <MoreIcon />.
    2. Click **Restore**.
    3. Read through the consequences and click **Yes, Restore**.
  </Tab>
</Tabs>

The data is restored and your backed-up environment is deployed.
This deployment uses the built app, including variables, from when the backup was taken.

<Warning>
  <h4>Warning</h4>
  The code is also initially restored, but Upsun doesn't modify your Git repository.
  So any future (re)deployments use the current Git repository to build the environment.

  To restore your code to its previous state when the backup was taken,
  use Git commands such as [revert](https://git-scm.com/docs/git-revert).

  Note that you can also opt out of restoring the code entirely by using the `--no-code` flag.
  For more information, see [how backup and restore works on Upsun](/docs/environments/backup#how-backup-and-restore-works).

  Also, see [how resource allocation works](/docs/manage-resources/resource-init#backup-restoration) when you restore a backup.
</Warning>

## Restore to a different environment

You can restore backups to a different environment than they were created on using the CLI:

1. Switch to the branch where the backup was created.
2. To restore your backup to an existing environment, run the following command:

   ```bash theme={null}
   upsun backup:restore --target=<TARGET_ENVIRONMENT_NAME> <BACKUP_ID>
   ```

   If your target environment doesn't exist yet, you can create it by [branching an existing environment](/docs/glossary#branch).
   The new target environment will be an exact copy of the existing (parent) environment.

   To do so, use the `--branch-from` option to specify the parent of your new target environment:

   ```bash theme={null}
   upsun backup:restore --target=<TARGET_ENVIRONMENT_NAME> --branch-from=<PARENT_ENVIRONMENT_NAME> <BACKUP_ID>
   ```
