Database Migration from Bitnami to Percona
This section explains how to migrate the pgvector database from a Bitnami PostgreSQL installation to a Percona PostgreSQL installation.
Backing Up and Restoring the pgvector Database
Set Environment
Variables
export NS=<namespace>
export RL=<release-name>Old Installation (Bitnami)
- Port-forward the pgvector
service
kubectl -n $NS port-forward svc/$RL-pgvector 5432:5432 - Get the database
password
export PGPASSWORD=$(kubectl -n $NS get secret $RL-postgres-password-secret -o jsonpath="{.data.postgres-password}" | base64 --decode) - Dump the
database
touch backup_schema.sql;pg_dump -U postgres -h localhost -p 5432 --schema-only --table=*langchain* --disable-triggers agenticbuilder > backup_schema.sql;pg_dump -U postgres -h localhost -p 5432 --data-only --on-conflict-do-nothing --inserts --disable-triggers agenticbuilder > backup_data.sql
New Installation (Percona)
- Port-forward the database pod
kubectl port-forward -n $NS \ $(kubectl get pod -l postgres-operator.crunchydata.com/cluster=$RL-pg-db -n $NS -o jsonpath="{.items[0].metadata.name}") \ 5432:5432 - Get the database user and
password
# Get user export PGUSER=$(kubectl -n $NS get secret $RL-pg-db-pguser-postgres -o jsonpath="{.data.user}" | base64 -d) # Get password export PGPASSWORD=$(kubectl -n $NS get secret $RL-pg-db-pguser-postgres -o jsonpath="{.data.password}" | base64 -d) - Restore the database
Before running the restore commands, set the required environment variables.
These values are the defaults defined in:
agenticAIBuilder.common.postgres.postgresDBagenticAIBuilder.common.postgres.postgresUser
export AGENTICBUILDER_DB=agenticbuilder export AGENTICBUILDER_USER=agenticbuilderRun the Database Restore Commands
Use the following commands to restore both schema and data, then update permissions on the required tables:
psql -d $AGENTICBUILDER_DB -U $PGUSER -h localhost -p 5432 -f backup_schema.sql \ && psql -d $AGENTICBUILDER_DB -U $PGUSER -h localhost -p 5432 -f backup_data.sql \ && psql -d $AGENTICBUILDER_DB -U $PGUSER -h localhost -p 5432 -c \ "GRANT ALL PRIVILEGES ON TABLE public.langchain_pg_collection, public.langchain_pg_embedding TO $AGENTICBUILDER_USER;"