DevOpsDocs Help

backup-and-restore-timescaledb

In Source Server

sudo -u postgres pg_dump wapp_activity -Fc -v > wa/dump.bak scp -r backup/wa root@w:/root/files/backup

In Target Server

TSPOD=`kubectl get pod -l app.kubernetes.io/name=timescaledb -o jsonpath='{.items[0].metadata.name}' -n database` alias kexec='kubectl exec -n database $TSPOD -ti -c timescaledb' alias kexecpsql='kubectl exec -n database $TSPOD -ti -c timescaledb' kubectl cp /root/files/backup/wa database/$TSPOD:/home/postgres/backup/bak-wa kexecpsql "create extension if not exists timescaledb;" kexecpsql "SELECT timescaledb_pre_restore();" kexec -- pg_restore -U postgres --no-owner -Fc -v -d postgres bak-wa/dump.bak kexecpsql "SELECT timescaledb_post_restore();" kexecpsql "ANALYZE;"
Last modified: 07 March 2024