Ok

En poursuivant votre navigation sur ce site, vous acceptez l'utilisation de cookies. Ces derniers assurent le bon fonctionnement de nos services. En savoir plus.

[POSTGRES] Easy to migrate

Little bash script

#!/bin/sh
if [ -z "$2" ] ; then echo "Usage: `basename $0` original-db new-db" ; exit 1 ; fi
echo "Copying schema of $1 to $2"
createdb "$2" 2> /dev/null

echo " You want to migrate from which server ?"

read SERVER_SOURCE

echo " Where do you want to migrate your data, name of target server please ?"

read SERVER_TARGET

echo "Listen we need you admin account : "

read USER
pg_dump --format c "$1" -h ${SERVER_SOURCE} -U ${USER} | pg_restore --dbname="$2" -h ${SERVER_TARGET} -U ${USER}

Les commentaires sont fermés.