diff --git a/doc/postgres_upgrade.md b/doc/postgres_upgrade.md index f79a2d069..3013b58dd 100644 --- a/doc/postgres_upgrade.md +++ b/doc/postgres_upgrade.md @@ -20,7 +20,7 @@ Once you've understood all the points above, you can run the migration script wi ```bash cd /apps/fabmanager # do not run as root, elevation will be prompted if needed -\curl \sSL https://raw.githubusercontent.com/sleede/fab-manager/master/scripts/postgre-upgrade.sh | bash +\curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/scripts/postgre-upgrade.sh | bash ``` ## Manual upgrade diff --git a/scripts/postgre-upgrade.sh b/scripts/postgre-upgrade.sh index 27315a4b8..737fe2475 100644 --- a/scripts/postgre-upgrade.sh +++ b/scripts/postgre-upgrade.sh @@ -107,28 +107,26 @@ prepare_path() fi } +docker_down() +{ + docker-compose down +} + pg_upgrade() { docker run --rm \ -v "$PG_PATH:/var/lib/postgresql/$OLD/data" \ -v "$NEW_PATH:/var/lib/postgresql/$NEW/data" \ "tianon/postgres-upgrade:$OLD-to-$NEW" --link - } upgrade_compose() { echo -e "\nUpgrading docker-compose installation from $OLD to $NEW..." - docker-compose stop postgres - docker-compose rm -f postgres # update image tag and data directory into docker-compose file awk "BEGIN { FS=\"\n\"; RS=\"\"; } { print gensub(/(image: postgres:$OLD(\n|.)+volumes:(\n|.)+(-.*postgresql\/data))/, \"image: postgres:$NEW\n volumes:\n - ${NEW_PATH}:/var/lib/postgresql/data\", \"g\") }" "$FM_PATH/docker-compose.yml" > "$FM_PATH/.awktmpfile" && mv "$FM_PATH/.awktmpfile" "$FM_PATH/docker-compose.yml" - - docker-compose pull - trust_pg_hba_conf - docker-compose up -d } trust_pg_hba_conf() @@ -141,6 +139,12 @@ trust_pg_hba_conf() } | "$COMMAND" -a "$NEW_PATH/pg_hba.conf" > /dev/null } +docker_up() +{ + docker-compose pull + docker-compose up -d +} + clean() { read -rp "Remove the previous PostgreSQL data folder? (y/N) " confirm