Skip to content

Kubernetes cluster transver

Peter Weber edited this page Feb 23, 2026 · 1 revision

copy_app.sh - Copy Kubernetes resources between clusters

This script exports Kubernetes resources from a source cluster, strips server-side metadata (uid, resourceVersion, etc.) using jq, adds app.kubernetes.io labels, and recreates them on a destination cluster.

Prerequisites: kubectl, jq Usage: bash copy_app.sh -a -s -d [-v] [-h] Example: bash copy_app.sh -a mef -s ctx-prod1 -d ctx-prod2

copy_db.sh - Copy PostgreSQL database between Kubernetes clusters

This script dumps a PostgreSQL database from a source cluster and restores it on a destination cluster. It reads DB credentials from Kubernetes configmaps and secrets.

Prerequisites: kubectl, jq Usage: bash copy_db.sh -a -s -d [-v] [-h] Example: bash copy_db.sh -a mef -s ctx-prod1 -d ctx-prod2

copy_es.sh - Copy Elasticsearch indices between Kubernetes clusters

This script copies all non-system Elasticsearch indices from a source ECK cluster to a destination ECK cluster using kubectl exec + curl (scroll API for export, bulk API for import).

Prerequisites: kubectl, jq Usage: bash copy_es.sh -a -s -d [-j ] [-e] [-r] [-y] [-v] [-h] Example: bash copy_es.sh -a mef -s ctx-prod1 -d ctx-prod2 bash copy_es.sh -a mef -s ctx-prod1 -e # export only bash copy_es.sh -a mef -d ctx-prod2 -r # restore only

copy_es_snapshot.sh - Copy Elasticsearch indices via shared snapshot repository

This script uses ES native snapshot/restore to migrate indices between ECK clusters. Requires a shared filesystem (NFS) mounted on both clusters. Much faster than scroll/bulk API for large datasets.

Prerequisites: kubectl, jq, shared filesystem mounted on both ES clusters Usage: bash copy_es_snapshot.sh -a -s -d -p [-y] [-v] [-h] Example: bash copy_es_snapshot.sh -a mef -s ctx-prod1 -d ctx-prod2 -p /mnt/shared/es-snapshots

copy_es_slm.sh - Copy Elasticsearch snapshot repositories and SLM policies

This script copies snapshot repository configurations and SLM (Snapshot Lifecycle Management) policies from a source ECK cluster to a destination ECK cluster using kubectl exec + curl.

Prerequisites: kubectl, jq Usage: bash copy_es_slm.sh -a -s -d [-y] [-v] [-h] Example: bash copy_es_slm.sh -a mef -s ctx-prod1 -d ctx-prod2