From dc539baa521b43c47ff88e2c3b49999c6ed32878 Mon Sep 17 00:00:00 2001 From: Gerasimos Tzakis Date: Thu, 14 Mar 2024 11:54:01 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=93=9D=20backup-restore=20procedur?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/operations/backup-restore.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/operations/backup-restore.md b/docs/operations/backup-restore.md index dacb6179..0cdda7a1 100644 --- a/docs/operations/backup-restore.md +++ b/docs/operations/backup-restore.md @@ -5,10 +5,9 @@ The recommended method of backing up Nautobot is simply to get a database dump from PostgreSQL: ```no-highlight -export NAMESPACE=nautobot # Be sure to use the correct namespace here export POSTGRES_SECRET_NAME=nautobot-postgresql # If you have changed the default make sure you change it here -export POSTGRES_PASSWORD=$(kubectl get secret --namespace $NAMESPACE $POSTGRES_SECRET_NAME -o jsonpath="{.data.postgresql-password}" | base64 --decode) -echo $POSTGRES_PASSWORD | kubectl exec -itn $NAMESPACE statefulset.apps/nautobot-postgresql -- pg_dump --username nautobot --clean --if-exists nautobot > backup.sql +export POSTGRES_PASSWORD=$(kubectl get secret --namespace $POSTGRES_SECRET_NAME -o jsonpath="{.data.password}" | base64 --decode) +echo $POSTGRES_PASSWORD | kubectl exec -it --namespace statefulset.apps/nautobot-postgresql -- pg_dump --username nautobot --clean --if-exists nautobot > backup.sql ``` NOTE: The name of the secret is dependent on the helm release name and may be different in your environment. @@ -16,19 +15,19 @@ NOTE: The name of the secret is dependent on the helm release name and may be di Make sure to save your `NAUTOBOT_SECRET_KEY` in a safe place as well: ```no-highlight -kubectl get secret nautobot-env -o jsonpath="{.data.NAUTOBOT_SECRET_KEY}" | base64 --decode +kubectl get secret --namespace nautobot-env -o jsonpath="{.data.NAUTOBOT_SECRET_KEY}" | base64 --decode ``` These commands specific to your deployment can be found by inspecting the notes provided after the install: ```no-highlight -helm status nautobot +helm status --namespace nautobot ``` In addition please make sure to note ALL values used to deploy this helm chart: ```no-highlight -helm get values -o yaml nautobot > nautobot.values.yaml +helm get values --namespace -o yaml nautobot > nautobot.values.yaml ``` As with any backup procedure, these steps should be validated in your environment before relying on them in production. @@ -40,13 +39,13 @@ This procedure assumes the [Backup Nautobot](#backup-nautobot) procedure was fol Install Nautobot using the previous helm values: ```no-highlight -helm install nautobot nautobot/nautobot -f nautobot.values.yaml +helm install --namespace nautobot nautobot/nautobot -f nautobot.values.yaml ``` Upload the backup and restore: ```no-highlight kubectl cp backup.sql nautobot-postgresql-0:/tmp -export POSTGRES_PASSWORD=$(kubectl get secret --namespace nautobot nautobot-postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode) -echo $POSTGRES_PASSWORD | kubectl exec -itn default statefulset.apps/nautobot-postgresql -- psql -U nautobot -f /tmp/backup.sql +export POSTGRES_PASSWORD=$(kubectl get secret --namespace nautobot-postgresql -o jsonpath="{.data.password}" | base64 --decode) +echo $POSTGRES_PASSWORD | kubectl exec -it --namespace statefulset.apps/nautobot-postgresql -- psql -U nautobot -f /tmp/backup.sql ```