mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
shut down instance before upgrading
This commit is contained in:
parent
95038313e9
commit
dabf32d774
@ -20,7 +20,7 @@ Once you've understood all the points above, you can run the migration script wi
|
|||||||
```bash
|
```bash
|
||||||
cd /apps/fabmanager
|
cd /apps/fabmanager
|
||||||
# do not run as root, elevation will be prompted if needed
|
# 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
|
## Manual upgrade
|
||||||
|
@ -107,28 +107,26 @@ prepare_path()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
docker_down()
|
||||||
|
{
|
||||||
|
docker-compose down
|
||||||
|
}
|
||||||
|
|
||||||
pg_upgrade()
|
pg_upgrade()
|
||||||
{
|
{
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-v "$PG_PATH:/var/lib/postgresql/$OLD/data" \
|
-v "$PG_PATH:/var/lib/postgresql/$OLD/data" \
|
||||||
-v "$NEW_PATH:/var/lib/postgresql/$NEW/data" \
|
-v "$NEW_PATH:/var/lib/postgresql/$NEW/data" \
|
||||||
"tianon/postgres-upgrade:$OLD-to-$NEW" --link
|
"tianon/postgres-upgrade:$OLD-to-$NEW" --link
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
upgrade_compose()
|
upgrade_compose()
|
||||||
{
|
{
|
||||||
echo -e "\nUpgrading docker-compose installation from $OLD to $NEW..."
|
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
|
# 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"
|
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()
|
trust_pg_hba_conf()
|
||||||
@ -141,6 +139,12 @@ trust_pg_hba_conf()
|
|||||||
} | "$COMMAND" -a "$NEW_PATH/pg_hba.conf" > /dev/null
|
} | "$COMMAND" -a "$NEW_PATH/pg_hba.conf" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
docker_up()
|
||||||
|
{
|
||||||
|
docker-compose pull
|
||||||
|
docker-compose up -d
|
||||||
|
}
|
||||||
|
|
||||||
clean()
|
clean()
|
||||||
{
|
{
|
||||||
read -rp "Remove the previous PostgreSQL data folder? (y/N) " confirm </dev/tty
|
read -rp "Remove the previous PostgreSQL data folder? (y/N) " confirm </dev/tty
|
||||||
@ -162,8 +166,11 @@ upgrade_postgres()
|
|||||||
read_path
|
read_path
|
||||||
test_free_space
|
test_free_space
|
||||||
prepare_path
|
prepare_path
|
||||||
|
docker_down
|
||||||
pg_upgrade
|
pg_upgrade
|
||||||
upgrade_compose
|
upgrade_compose
|
||||||
|
trust_pg_hba_conf
|
||||||
|
docker_up
|
||||||
clean
|
clean
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user