Skip to content

Instantly share code, notes, and snippets.

@cime
Forked from jgillman/restore.sh
Last active July 13, 2018 17:14
Show Gist options
  • Save cime/a9e73fdd2a291413a9c07d3d6cb1fb17 to your computer and use it in GitHub Desktop.
Save cime/a9e73fdd2a291413a9c07d3d6cb1fb17 to your computer and use it in GitHub Desktop.

Revisions

  1. cime renamed this gist Jul 13, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions restore.sh → pg_restore_docker.sh
    Original file line number Diff line number Diff line change
    @@ -6,5 +6,6 @@ DB_USER=postgres
    LOCAL_DUMP_PATH="path/to/local.dump"

    docker-compose up -d db
    sleep 5
    docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_NAME}" < "${LOCAL_DUMP_PATH}"
    docker-compose stop db
  2. cime revised this gist Jul 13, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion restore.sh
    Original file line number Diff line number Diff line change
    @@ -7,4 +7,4 @@ LOCAL_DUMP_PATH="path/to/local.dump"

    docker-compose up -d db
    docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_NAME}" < "${LOCAL_DUMP_PATH}"
    docker-compose stop db
    docker-compose stop db
  3. cime revised this gist Jul 13, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions restore.sh
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    # Assumes the database container is named 'db'

    DOCKER_DB_NAME="$(docker-compose ps -q db)"
    DB_HOSTNAME=db
    DB_NAME=db
    DB_USER=postgres
    LOCAL_DUMP_PATH="path/to/local.dump"

    docker-compose up -d db
    docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
    docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_NAME}" < "${LOCAL_DUMP_PATH}"
    docker-compose stop db
  4. @jgillman jgillman renamed this gist May 7, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. @jgillman jgillman revised this gist May 7, 2016. No changes.
  6. @jgillman jgillman created this gist May 7, 2016.
    10 changes: 10 additions & 0 deletions restore
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # Assumes the database container is named 'db'

    DOCKER_DB_NAME="$(docker-compose ps -q db)"
    DB_HOSTNAME=db
    DB_USER=postgres
    LOCAL_DUMP_PATH="path/to/local.dump"

    docker-compose up -d db
    docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
    docker-compose stop db