diff --git a/mintlify/change-database/rollback-data-changes.mdx b/mintlify/change-database/rollback-data-changes.mdx index ccf4739f3..a24521fcb 100644 --- a/mintlify/change-database/rollback-data-changes.mdx +++ b/mintlify/change-database/rollback-data-changes.mdx @@ -10,12 +10,11 @@ feature_name: 'ROLLBACK_DATA_CHANGES' horizontal /> -Bytebase allows taking **Prior Backup** before a data change is made. Bytebase stores the pre-snapshot of the affected rows, which allows you to revert that data change if needed. +Bytebase provides **Prior Backup** functionality that captures a snapshot of data before changes are applied. This safety mechanism stores the original state of affected rows, enabling you to revert data changes with **1-Click** when necessary. You can perform **multi-task rollbacks** to efficiently revert multiple related changes across databases in one operation. -The backup data is stored in your own database instance. Bytebase does not purge the backup data automatically. -You can manually delete the data in `bbdataarchive` database/schema. +Backup data is stored within your own database instance in a dedicated `bbdataarchive` location. Bytebase does not automatically purge this backup data, so you can manually clean up the `bbdataarchive` database or schema as needed. @@ -30,73 +29,85 @@ You can manually delete the data in `bbdataarchive` database/schema. ## Supported Operations -We are working on enabling backup and 1-click rollback for more SQL statements. +Bytebase continues to expand backup and rollback support for additional SQL statement types. ### Feasibility Conditions Prior backup is feasible when meeting **all** of the following conditions: - The SQL statement size is less than 2M. - - No mixed `UPDATE`/`DELETE` on the same table. - - No mixed DDL/DML. 1-click rollback is feasible when meeting **all** of the following conditions: - For `UPDATE`, the changed table has primary key and primary key columns are not updated. -## Create backup +## Enable Prior Backup + +You can enable the **Prior Backup** option either before or after creating a database change issue. + + ![bb-issue-backup-on](/content/docs/change-database/rollback-data-changes/bb-issue-backup-on.webp) -You can toggle **Prior Backup** switch before or after creating the issue. + +If the Prior Backup switch appears disabled, navigate to the database page and click **Sync instance** to refresh the database metadata. + -![bb-prior-bk-on](/content/docs/change-database/rollback-data-changes/bb-prior-bk-on.webp) +## Perform 1-Click and Multi-Task Rollback -If the switch is disabled, go to the database page and click **Sync instance** first. +1. After your database change has been successfully deployed, click the **Rollback available** link to initiate the rollback process. -## 1-click rollback + ![bb-issue-done-1](/content/docs/change-database/rollback-data-changes/bb-issue-done-1.webp) -1. Once the change has been rolled out. You can click the **Rollback** button to create the rollback issue. +1. You may see multiple rollbackable changes available, depending on your deployment scenario. - ![bb-prior-bk-rollback](/content/docs/change-database/rollback-data-changes/bb-prior-bk-rollback.webp) + + This could include a single change applied to multiple databases, multiple changes to one database, or a combination of both scenarios. + -1. The rollback issue automatically populates the rollback statements. + ![bb-issue-done-2](/content/docs/change-database/rollback-data-changes/bb-issue-done-2.webp) - ![bb-prior-bk-rollback-issue](/content/docs/change-database/rollback-data-changes/bb-prior-bk-rollback-issue.webp) +1. Select which changes you want to rollback - you can choose individual changes or rollback all of them at once. This **multi-task rollback** capability allows you to efficiently revert multiple related changes in a single operation. -## Inspect the backup data + ![bb-rollback-select](/content/docs/change-database/rollback-data-changes/bb-rollback-select.webp) -You can go to SQL Editor to inspect the backup data. If the DML change contains no more than 5 statements, then each -statements will be backed up to a separate table. +1. Bytebase automatically generates the appropriate rollback SQL statements based on the backup data. -![bb-prior-bk-separate-table](/content/docs/change-database/rollback-data-changes/bb-prior-bk-separate-table.webp) + ![bb-rollback-issue-1](/content/docs/change-database/rollback-data-changes/bb-rollback-issue-1.webp) -If the DML change contains more than 5 statements, then all statements will be backed up to a single table. + ![bb-rollback-issue-2](/content/docs/change-database/rollback-data-changes/bb-rollback-issue-2.webp) -![bb-prior-bk-single-table-issue](/content/docs/change-database/rollback-data-changes/bb-prior-bk-single-table-issue.webp) +## Inspect Backup Data -![bb-prior-bk-single-table](/content/docs/change-database/rollback-data-changes/bb-prior-bk-single-table.webp) +You can examine the stored backup data using Bytebase's SQL Editor to verify what information has been preserved. -## Project backup settings + ![bb-sql-editor-test](/content/docs/change-database/rollback-data-changes/bb-sql-editor-test.webp) + ![bb-sql-editor-prod](/content/docs/change-database/rollback-data-changes/bb-sql-editor-prod.webp) -- You can enable **Prior Backup** by default. -- You can control whether you want to skip backup errors and continue changing the data. +## Project Backup Settings -![prior-backup-default](/content/docs/change-database/rollback-data-changes/bb-prior-backup-default.webp) +Configure backup behavior at the project level for consistent data protection: + +- **Default backup**: Enable **Prior Backup** by default for all changes in the project +- **Error handling**: Control whether to skip backup errors and proceed with data changes + + ![prior-backup-default](/content/docs/change-database/rollback-data-changes/bb-prior-backup-default.webp) ## Appendix: Setting Up `bbdataarchive` +Before using Prior Backup functionality, you must create the `bbdataarchive` storage location in your database instance. Follow the instructions for your specific database engine: + ### MySQL -1. Create the `bbdataarchive` Database: +1. **Create the backup database:** ```sql CREATE DATABASE bbdataarchive; ``` -1. Grant Necessary Privileges: +1. **Grant necessary privileges:** - Replace `your_user` with the actual username. + Replace `your_user` with the actual username that Bytebase uses to connect to your database. ```sql GRANT ALL PRIVILEGES ON bbdataarchive.* TO 'your_user'@'%'; @@ -105,15 +116,15 @@ If the DML change contains more than 5 statements, then all statements will be b ### PostgreSQL -1. Create the `bbdataarchive` Schema: +1. **Create the backup schema:** ```sql CREATE SCHEMA bbdataarchive; ``` -1. Grant Necessary Privileges: +1. **Grant necessary privileges:** - Replace `your_user` with the actual username. + Replace `your_user` with the actual username that Bytebase uses to connect to your database. ```sql GRANT ALL PRIVILEGES ON SCHEMA bbdataarchive TO your_user; @@ -122,29 +133,29 @@ If the DML change contains more than 5 statements, then all statements will be b ### Oracle -1. Create the `bbdataarchive` User: +1. **Create the backup user:** ```sql CREATE USER bbdataarchive IDENTIFIED BY password; ``` -1. Grant Connection Privileges: +1. **Grant connection privileges:** ```sql GRANT CREATE SESSION TO bbdataarchive; ``` -1. Grant unlimited space quota to the `bbdataarchive` user on the specified `tablespace`: +1. **Grant unlimited space quota:** - Replace `tablespace_name` with the actual tablespace name. + Replace `tablespace_name` with your actual tablespace name. ```sql GRANT QUOTA UNLIMITED ON tablespace_name TO bbdataarchive; ``` -1. Grant Privileges to the Instance Administrator: +1. **Grant privileges to the instance administrator:** - Replace `admin_user` with the actual username of the instance administrator. + Replace `admin_user` with the actual username that Bytebase uses as the instance administrator. ```sql GRANT CREATE ANY TABLE TO admin_user; @@ -153,15 +164,15 @@ If the DML change contains more than 5 statements, then all statements will be b ### SQL Server -1. Create the `bbdataarchive` Database: +1. **Create the backup database:** ```sql CREATE DATABASE bbdataarchive; ``` -1. Grant Necessary Privileges: +1. **Grant necessary privileges:** - Replace `your_user` with the actual username. + Replace `your_user` with the actual username that Bytebase uses to connect to your database. ```sql USE bbdataarchive; diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-issue-backup-on.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-issue-backup-on.webp new file mode 100644 index 000000000..efaca9d70 Binary files /dev/null and b/mintlify/content/docs/change-database/rollback-data-changes/bb-issue-backup-on.webp differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-issue-done-1.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-issue-done-1.webp new file mode 100644 index 000000000..4dba2b76c Binary files /dev/null and b/mintlify/content/docs/change-database/rollback-data-changes/bb-issue-done-1.webp differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-issue-done-2.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-issue-done-2.webp new file mode 100644 index 000000000..23927207f Binary files /dev/null and b/mintlify/content/docs/change-database/rollback-data-changes/bb-issue-done-2.webp differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-on.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-on.webp deleted file mode 100644 index cc09ad689..000000000 Binary files a/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-on.webp and /dev/null differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-rollback-issue.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-rollback-issue.webp deleted file mode 100644 index 3eade38e3..000000000 Binary files a/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-rollback-issue.webp and /dev/null differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-rollback.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-rollback.webp deleted file mode 100644 index ab5ea3728..000000000 Binary files a/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-rollback.webp and /dev/null differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-separate-table.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-separate-table.webp deleted file mode 100644 index 98a644653..000000000 Binary files a/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-separate-table.webp and /dev/null differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-single-table-issue.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-single-table-issue.webp deleted file mode 100644 index 5fc1f6977..000000000 Binary files a/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-single-table-issue.webp and /dev/null differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-single-table.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-single-table.webp deleted file mode 100644 index 2806344e0..000000000 Binary files a/mintlify/content/docs/change-database/rollback-data-changes/bb-prior-bk-single-table.webp and /dev/null differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-rollback-issue-1.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-rollback-issue-1.webp new file mode 100644 index 000000000..92e7bb51f Binary files /dev/null and b/mintlify/content/docs/change-database/rollback-data-changes/bb-rollback-issue-1.webp differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-rollback-issue-2.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-rollback-issue-2.webp new file mode 100644 index 000000000..b8185b7a2 Binary files /dev/null and b/mintlify/content/docs/change-database/rollback-data-changes/bb-rollback-issue-2.webp differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-rollback-select.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-rollback-select.webp new file mode 100644 index 000000000..12a5e678a Binary files /dev/null and b/mintlify/content/docs/change-database/rollback-data-changes/bb-rollback-select.webp differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-sql-editor-prod.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-sql-editor-prod.webp new file mode 100644 index 000000000..c717cab54 Binary files /dev/null and b/mintlify/content/docs/change-database/rollback-data-changes/bb-sql-editor-prod.webp differ diff --git a/mintlify/content/docs/change-database/rollback-data-changes/bb-sql-editor-test.webp b/mintlify/content/docs/change-database/rollback-data-changes/bb-sql-editor-test.webp new file mode 100644 index 000000000..553872948 Binary files /dev/null and b/mintlify/content/docs/change-database/rollback-data-changes/bb-sql-editor-test.webp differ