Skip to content

Latest commit

 

History

History
66 lines (46 loc) · 2.25 KB

snapshot-recovery.md

File metadata and controls

66 lines (46 loc) · 2.25 KB

Recover from a snapshot

This guide provides instructions on how to use the restore.sh script to restore a kamaji-etcd datastore from a snapshot.

Overview

The script performs the following steps:

  1. Scales down the etcd StatefulSet to zero replicas.
  2. Waits for the etcd pods to be deleted.
  3. Creates a restore job for each etcd member (assumes three members) to restore the data from the snapshot.
  4. Waits for each restore job to complete.
  5. Scales the etcd StatefulSet back to three replicas.

Requirements

  • 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 where kamaji-etcd is running.

Creating the Secret

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>

Usage

To run the script, use the following command:

./restore.sh [-e etcd_name] [-s etcd_service] [-n etcd_namespace] [-f snapshot]

Parameters

  • -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

Notes

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

Debug mode

To run the script in debug mode set the environment variable DEBUG:

export DEBUG=1