Back up a NoSQL database in a Kubernetes environment
This guide explains how to create a transactionally consistent backup of managed databases that ScalarDB or ScalarDL uses in a Kubernetes environment. Please note that, when using a NoSQL database or multiple databases, you must pause ScalarDB or ScalarDL to create a transactionally consistent backup.
For details on how ScalarDB backs up databases, see A Guide on How to Backup and Restore Databases Used Through ScalarDB.
In this guide, we assume that you are using point-in-time recovery (PITR) or its equivalent features. Therefore, we must create a period where there are no ongoing transactions for restoration. You can then restore data to that specific period by using PITR. If you restore data to a time without creating a period where there are no ongoing transactions, the restored data could be transactionally inconsistent, causing ScalarDB or ScalarDL to not work properly with the data.
Create a period to restore data, and perform a backup
- Check the following four points by running the
kubectl get pod
command before starting the backup operation:- The number of ScalarDB or ScalarDL pods. Write down the number of pods so that you can compare that number with the number of pods after performing the backup.
- The ScalarDB or ScalarDL pod names in the
NAME
column. Write down the pod names so that you can compare those names with the pod names after performing the backup. - The ScalarDB or ScalarDL pod status is
Running
in theSTATUS
column. Confirm that the pods are running before proceeding with the backup. You will need to pause the pods in the next step. - The restart count of each pod in the
RESTARTS
column. Write down the restart count of each pod so that you can compare the count with the restart counts after performing the backup.
- Pause the ScalarDB or ScalarDL pods by using
scalar-admin
. For details on how to pause the pods, see the Details on usingscalar-admin
section in this guide. - Write down the
pause completed
time. You will need to refer to that time when restoring the data by using the PITR feature. - Back up each database by using the backup feature. If you have enabled the automatic backup and PITR features, the managed databases will perform back up automatically. Please note that you should wait for approximately 10 seconds so that you can create a sufficiently long period to avoid a clock skew issue between the client clock and the database clock. This 10-second period is the exact period in which you can restore data by using the PITR feature.
- Unpause ScalarDB or ScalarDL pods by using
scalar-admin
. For details on how to unpause the pods, see the Details on usingscalar-admin
section in this guide. - Check the
unpause started
time. You must check theunpause started
time to confirm the exact period in which you can restore data by using the PITR feature. - Check the pod status after performing the backup. You must check the following four points by using the
kubectl get pod
command after the backup operation is completed.- The number of ScalarDB or ScalarDL pods. Confirm this number matches the number of pods that you wrote down before performing the backup.
- The ScalarDB or ScalarDL pod names in the
NAME
column. Confirm the names match the pod names that you wrote down before performing the backup. - The ScalarDB or ScalarDL pod status is
Running
in theSTATUS
column. - The restart count of each pod in the
RESTARTS
column. Confirm the counts match the restart counts that you wrote down before performing the backup
unpause
state. Pods in theunpause
state will cause the backup data to be transactionally inconsistent. - (Amazon DynamoDB only) If you use the PITR feature of DynamoDB, you will need to perform additional steps to create a backup because the feature restores data with another name table by using PITR. For details on the additional steps after creating the exact period in which you can restore the data, please see Restore databases in a Kubernetes environment.
Back up multiple databases
If you have two or more databases that the Multi-storage Transactions or Two-phase Commit Transactions feature uses, you must pause all instances of ScalarDB or ScalarDL and create the same period where no ongoing transactions exist in the databases.
To ensure consistency between multiple databases, you must restore the databases to the same point in time by using the PITR feature.