Back up Data
Bytebase manages its own data under the --data directory. The data includes:
- Metadata when --pg is not specified.
- Database backups when cloud backup flags is not specified.
Embedded PostgreSQL Metadata
By default, Bytebase bundles an embedded PostgreSQL instance for storing its own metadata. The metadata is stored under the --data
directory. You can back up the --data
direcotry or the pgdata
subfolder.
External PostgreSQL Metadata
If --pg is specified, the metadata will be stored in the specified external PostgreSQL database. Below shows how to back up and restore the Bytebase metadata, let's assume the metadata is stored in metadb
.
Back up the metadata
Restore Option 1 - Restore to the same metadb
Step 1 - Restore metadata to a temporary db
Create a new db metadb_new
:
Restore metdata to the new db:
Step 2 - Swap the existing metadata db with the temporary db
Rename existing metadb
to metadb_old
:
Rename metadb_new
to the metadb
, which will serve as the new metadata db:
Step 3 - Drop the old metadata db
Restart Bytebase and verify the metadata is restored properly. Afterwards, you can drop the old database:
Restore Option 2 - Restore to a different database metadb2
Step 1 - Modify the dump file
The dump file records the Bytebase metadata schema change history, and it's database specific. So we
need to change the existing record value from metadb
to metadb2
first, which means to transfer
the change history to metadb2
.
Locate the migration_history
table in the dump file, and for each record, find the value metadb
which corresponds to the namespace
column, change each occurrence from metadb
to metadb2
.
Step 2 - Restore metadata to metadb2
Create a new db metadb2
:
Restore metdata to the new db:
Step 3 - Drop the old metadata db
Restart Bytebase and verify the metadata is restored properly. Afterwards, you can drop the old database:
Database Backup
Bytebase allows users to take database backups.
-
Local backup:
backup
directory will be put under the--data
directory. -
Cloud backup: If Bytebase starts with cloud backup flags, then the backup will be stored in the corresponding cloud storage.