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

# Data Change with 1-Click Rollback

When modifying data in production databases, having a backup is crucial for quick recovery from mistakes. Bytebase's [**1-Click Data Rollback**](/change-database/rollback-data-changes/) feature automatically creates backups before data changes and allows instant rollback when needed. This tutorial demonstrates how to use this feature and configure automatic backups.

<img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/data-rollback/rollback-graph.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=70df1bb88422cfb2366529e58b0afb4d" alt="rollback-graph" width="789" height="448" data-path="content/docs/tutorials/data-rollback/rollback-graph.webp" />

## Step 1 - Start Bytebase with sample data

1. Ensure Docker is running, then start the Bytebase container:

   ```bash theme={null}
   docker run --rm --init \
     --name bytebase \
     --publish 8080:8080 --pull always \
     --volume ~/.bytebase/data:/var/opt/bytebase \
     bytebase/bytebase:latest
   ```

   <img src="https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/content/docs/tutorials/shared/dk-bb-running.webp?fit=max&auto=format&n=vw8BbfZhlW9y-cr_&q=85&s=cf0be18b5f9bfc3ff7c06b8276cd2466" alt="dk-bb-running" width="1536" height="120" data-path="content/docs/tutorials/shared/dk-bb-running.webp" />

2. Open Bytebase in [localhost:8080](http://localhost:8080/), fill in the fields and click **Create admin account**. You'll be redirected to Workspace.

   <img src="https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/content/docs/tutorials/shared/account.webp?fit=max&auto=format&n=vw8BbfZhlW9y-cr_&q=85&s=89bfcf723a14ae15e941e00db24435b4" alt="account" width="3840" height="1936" data-path="content/docs/tutorials/shared/account.webp" />

3. During workspace setup, choose the built-in sample data.

   <img src="https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/content/docs/tutorials/shared/bb-setup-built-in-sample.webp?fit=max&auto=format&n=vw8BbfZhlW9y-cr_&q=85&s=8950dabf39d43da14c0e690c95084a48" alt="setup-built-in-sample-data" width="1024" height="664" data-path="content/docs/tutorials/shared/bb-setup-built-in-sample.webp" />

## Step 2 - Verify backup schema

Bytebase stores backup data in a dedicated `bbdataarchive` schema (for PostgreSQL) that's automatically created with our sample databases.

1. Navigate to `Sample Project` > **Database > Databases**.
2. Select `hr_test` to see the `bbdataarchive` schema already in place.

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/data-rollback/bb-hr_test-bbdataarchive.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=db76020e328a4107715dddb69eef08b0" alt="hr_test-bbdataarchive" width="2542" height="1186" data-path="content/docs/tutorials/data-rollback/bb-hr_test-bbdataarchive.webp" />

## Step 3 - Execute data change with backup

1. Open **SQL Editor**, select `hr_test`, and double-click the `employee` table to view current data. Note that employee 10001's first name is `Georgi`.

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/data-rollback/bb-sql-editor-before-change.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=0f2cafa4d524c1777a13e75e2f980d06" alt="bb-sql-editor-before-change" width="2544" height="1192" data-path="content/docs/tutorials/data-rollback/bb-sql-editor-before-change.webp" />

2. Navigate to `Sample Project` > **CI/CD > Plans**. Click **+New Plan**, select **Data Change**, choose the `hr_test` database, then click **Confirm**.

3. Enable **Prior Backup** at the bottom of the form. Enter the following SQL:

   ```sql theme={null}
   UPDATE employee SET first_name = 'Adela' WHERE emp_no = 10001;
   ```

   Click **Create**, then **Ready for review**.

4. Go to the **Rollout** tab and click **Run** to execute the change.

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/data-rollback/bb-to-rollout.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=00e217bb4e13855015141ce8496558b2" alt="bb-to-rollout" width="2112" height="490" data-path="content/docs/tutorials/data-rollback/bb-to-rollout.webp" />

5. After execution, check the **Overview** tab to see the backup confirmation message.

6. To verify the change, return to **SQL Editor** and run:

   ```sql theme={null}
      SELECT * FROM "public"."employee" ORDER BY emp_no LIMIT 50;
   ```

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/data-rollback/bb-sql-editor-after-change.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=010cbd2ed898e40ee7fa906d86d2fd68" alt="sql-editor-after-change" width="2548" height="1194" data-path="content/docs/tutorials/data-rollback/bb-sql-editor-after-change.webp" />

7. To view the backup, switch to the `bbdataarchive` schema and double-click the backup table to see the original data preserved.

## Step 4 - Perform 1-Click rollback

1. In the **Rollout** tab, click the **Rollback** button next to the completed change.

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/data-rollback/bb-rollback-available.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=edbd3865b268bb39a9546e2ebc2e10af" alt="rollback-available" width="2140" height="628" data-path="content/docs/tutorials/data-rollback/bb-rollback-available.webp" />

2. Review the generated rollback SQL, click **Confirm**, then **Ready for Review**, and finally **Rollout** to execute.

3. Return to **SQL Editor** to verify the data has been restored to its original state.

## Step 5 - Configure automatic backups

1. Navigate to project **Settings** to find these backup options under **Issue related**:

   * **Auto enable backup**: Automatically backs up data for all data changes
   * **Skip backup errors**: Continues with changes even if backup fails

   Enable these options to avoid manually selecting backup for each data change.

## Database-specific considerations

For MySQL, SQL Server, and Oracle, Bytebase uses a separate `bbdataarchive` **database** rather than a schema to store backups. See the documentation below for details.

<Card title="Data Rollback Doc" icon="book" href="/change-database/rollback-data-changes/" horizontal />
