Last active
October 16, 2022 03:57
-
-
Save nhthai2005/ce7b5672a7c1b79ee22b8b952320fb3b to your computer and use it in GitHub Desktop.
Migration postgres data from 9.6 to 14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# MAINTAINER: NGUYEN HONG THAI | |
if [ $# -eq 2 ]; then | |
old_data=$(realpath $1) | |
new_data=$(realpath $2) | |
else | |
read -p "old_data: " old_data | |
old_data=$(realpath $old_data) | |
read -p "new_data: " new_data | |
new_data=$(realpath $new_data) | |
fi | |
docker run --rm -it --name pg_upgrade \ | |
-v $old_data:/var/lib/postgresql/9.6/data \ | |
-v $new_data:/var/lib/postgresql/13/data \ | |
-u postgres nhthai2005/pg_upgrade:9.6-to-13 \ | |
bash -c '$PGBINOLD/pg_ctl start -w -D $PGDATAOLD && $PGBINOLD/pg_ctl stop -w -D $PGDATAOLD' | |
docker run --rm --name pg_upgrade \ | |
-v $old_data:/var/lib/postgresql/9.6/data \ | |
-v $new_data:/var/lib/postgresql/13/data \ | |
nhthai2005/pg_upgrade:9.6-to-13 | |
docker run --rm -it --name pg_upgrade \ | |
-v $old_data:/var/lib/postgresql/9.6/data \ | |
-v $new_data:/var/lib/postgresql/13/data \ | |
-u postgres nhthai2005/pg_upgrade:9.6-to-13 \ | |
bash -c '$PGBINNEW/pg_ctl start -w -D $PGDATANEW && $PGBINNEW/vacuumdb --all --analyze-in-stages && $PGBINNEW/pg_ctl stop -w -D $PGDATANEW' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# MAINTAINER: NGUYEN HONG THAI | |
if [ $# -eq 2 ]; then | |
old_data=$(realpath $1) | |
new_data=$(realpath $2) | |
else | |
read -p "old_data: " old_data | |
old_data=$(realpath $old_data) | |
read -p "new_data: " new_data | |
new_data=$(realpath $new_data) | |
fi | |
docker run --rm -it --name pg_upgrade \ | |
-v $old_data:/var/lib/postgresql/9.6/data \ | |
-v $new_data:/var/lib/postgresql/14/data \ | |
-u postgres nhthai2005/pg_upgrade:9.6-to-14 \ | |
bash -c '$PGBINOLD/pg_ctl start -w -D $PGDATAOLD && $PGBINOLD/pg_ctl stop -w -D $PGDATAOLD' | |
docker run --rm --name pg_upgrade \ | |
-v $old_data:/var/lib/postgresql/9.6/data \ | |
-v $new_data:/var/lib/postgresql/14/data \ | |
nhthai2005/pg_upgrade:9.6-to-14 | |
docker run --rm -it --name pg_upgrade \ | |
-v $old_data:/var/lib/postgresql/9.6/data \ | |
-v $new_data:/var/lib/postgresql/14/data \ | |
-u postgres nhthai2005/pg_upgrade:9.6-to-14 \ | |
bash -c '$PGBINNEW/pg_ctl start -w -D $PGDATANEW && $PGBINNEW/vacuumdb --all --analyze-in-stages && $PGBINNEW/pg_ctl stop -w -D $PGDATANEW' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# MAINTAINER: NGUYEN HONG THAI | |
if [ $# -eq 2 ]; then | |
old_data=$(realpath $1) | |
new_data=$(realpath $2) | |
else | |
read -p "old_data: " old_data | |
old_data=$(realpath $old_data) | |
read -p "new_data: " new_data | |
new_data=$(realpath $new_data) | |
fi | |
docker run --rm -it --name pg_upgrade \ | |
-v $old_data:/var/lib/postgresql/9.6/data \ | |
-v $new_data:/var/lib/postgresql/15/data \ | |
-u postgres nhthai2005/pg_upgrade:9.6-to-15 \ | |
bash -c '$PGBINOLD/pg_ctl start -w -D $PGDATAOLD && $PGBINOLD/pg_ctl stop -w -D $PGDATAOLD' | |
docker run --rm --name pg_upgrade \ | |
-v $old_data:/var/lib/postgresql/9.6/data \ | |
-v $new_data:/var/lib/postgresql/15/data \ | |
nhthai2005/pg_upgrade:9.6-to-15 | |
docker run --rm -it --name pg_upgrade \ | |
-v $old_data:/var/lib/postgresql/9.6/data \ | |
-v $new_data:/var/lib/postgresql/15/data \ | |
-u postgres nhthai2005/pg_upgrade:9.6-to-15 \ | |
bash -c '$PGBINNEW/pg_ctl start -w -D $PGDATANEW && $PGBINNEW/vacuumdb --all --analyze-in-stages && $PGBINNEW/pg_ctl stop -w -D $PGDATANEW' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment