This guide provides instructions on how to use the restore.sh
script to restore a kamaji-etcd
datastore from a snapshot.
The script performs the following steps:
- Scales down the
etcd
StatefulSet to zero replicas. - Waits for the
etcd
pods to be deleted. - Creates a restore job for each
etcd
member (assumes three members) to restore the data from the snapshot. - Waits for each restore job to complete.
- Scales the
etcd
StatefulSet back to three replicas.
- Ensure you have
kubectl
installed and configured to interact with the management cluster. - The snapshot should be taken previously with the
backup.sh
script. It is assumed that the snapshot file is stored on an S3-like storage. - A kubernetes secret called
backup-storage-secret
containing the parameters and credentials to access the storage must be created in the same namespace wherekamaji-etcd
is running.
To create the secret, use the following command:
kubectl create secret generic backup-storage-secret \
--from-literal=storage-url=<storage_url> \
--from-literal=storage-access-key=<access_key> \
--from-literal=storage-secret-key=<access_secret> \
--from-literal=storage-bucket-name=<bucket_name> \
--from-literal=storage-bucket-folder=<bucket_folder> \
-n <etcd_namespace>
To run the script, use the following command:
./restore.sh [-e etcd_name] [-s etcd_service] [-n etcd_namespace] [-f snapshot]
-e etcd_name
: Name of the etcd StatefulSet (default:kamaji-etcd
)-s etcd_service
: Name of the etcd service (default:kamaji-etcd
)-n etcd_namespace
: Namespace of the etcd StatefulSet (default:kamaji-system
)-f snapshot
: Snapshot file to restore from (required)
For example:
./restore.sh -e my-etcd -s my-etcd-service -n my-namespace -f snapshot.db
- Ensure that the snapshot file is accessible and the necessary secret for accessing the storage is configured in the same namespace.
- The script uses
kubectl
commands, so ensure you have the necessary permissions to perform these operations.
To run the script in debug mode set the environment variable DEBUG
:
export DEBUG=1