docs
Administration
Backup data

Frabit manages its own data under the --data directory. The data includes:

You should periodically back up the entire --data directory if any data is stored there.

If Bytebase is running and not in the readonly mode, and you want to take the backup, then the underlying data volume must support snapshot feature where the entire directory can take a snapshot at the same time, otherwise it may produce a corrupted backup bundle.

MySQL 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.

Back up the metadata

mysqldump -h <<host>> -p <<port>> -u <<user>> -d metadb > metadb.sql

Restore Option 1 - Restore to the same metadb

Step 1 - Restore metadata to a temporary db

Create a new db metadb_new:

mysql -h <<host>> -p <<port>> -U <<user>> metadb -c "CREATE DATABASE metadb_new"

Step 2 - Swap the existing metadata db with the temporary db

You need to first stop Bytebase otherwise its connection to the metadata db will prevent renaming the database.

Also, you can not rename the connecting database so you need to connect to the PostgreSQL instance using a different database like postgres.

psql -h <<host>> -p <<port>> -U <<user>> postgres -c "ALTER DATABASE metadb RENAME TO metadb_old"

Rename metadb_new to the metadb, which will serve as the new metadata db:

psql -h <<host>> -p <<port>> -U <<user>> postgres -c "ALTER DATABASE metadb_new RENAME TO metadb"

Step 3 - Drop the old metadata db

Restart Frabit and verify the metadata is restored properly. Afterwards, you can drop the old database:

psql -h <<host>> -p <<port>> -U <<user>> postgres -c "DROP DATABASE metadb_old"

Restore Option 2 - Restore to a different database metadb2

Step 1 - Modify the dump file

The dump file records the Frabit 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.

change-migration-history

Step 2 - Restore metadata to metadb2

Create a new db metadb2:

psql -h <<host>> -p <<port>> -U <<user>> metadb -c "CREATE DATABASE metadb2"

Restore metdata to the new db:

psql -h <<host>> -p <<port>> -U <<user>> metadb2 < metadb.sql

Step 3 - Drop the old metadata db

Restart Bytebase and verify the metadata is restored properly. Afterwards, you can drop the old database:

psql -h <<host>> -p <<port>> -U <<user>> postgres -c "DROP DATABASE metadb"

Database Backup

Frabit allows users to take database backups.

  • Local backup: backup directory will be put under the --data directory.

  • Ultimate backup: If Bytebase starts with cloud backup flags, then the backup will be stored in the corresponding cloud storage.