Skip to content

Instantly share code, notes, and snippets.

@plunix
Forked from ricjcosme/dump-restore
Created December 30, 2019 11:41
Show Gist options
  • Save plunix/c62dfc51114e13b1f3d5d1a750584053 to your computer and use it in GitHub Desktop.
Save plunix/c62dfc51114e13b1f3d5d1a750584053 to your computer and use it in GitHub Desktop.

Revisions

  1. @ricjcosme ricjcosme created this gist Sep 13, 2017.
    11 changes: 11 additions & 0 deletions dump-restore
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    DUMP
    // pod-name name of the postgres pod
    // postgres-user database user that is able to access the database
    // database-name name of the database
    kubectl exec [pod-name] -- bash -c "pg_dump -U [postgres-user] [database-name]" > database.sql

    RESTORE
    // pod-name name of the postgres pod
    // postgres-user database user that is able to access the database
    // database-name name of the database
    cat database.sql | kubectl exec -i [pod-name] -- psql -U [postgres-user] -d [database-name]