Skip to content

Instantly share code, notes, and snippets.

@madssj
Last active December 25, 2015 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madssj/6920108 to your computer and use it in GitHub Desktop.
Save madssj/6920108 to your computer and use it in GitHub Desktop.
A shell script to upgrade between versions of PostgreSQL on Debian. Use at your own risk.
#!/bin/sh
if [ $# -ne 2 ]
then
echo "Usage: $0 <from> <to>"
exit 1
fi
from=$1
to=$2
for s in $from $to
do
ln -s /etc/postgresql/$s/main/*.conf /var/lib/postgresql/$s/main/
done
/usr/lib/postgresql/$to/bin/pg_upgrade \
-k \
-b /usr/lib/postgresql/$from/bin \
-B /usr/lib/postgresql/$to/bin \
-d /var/lib/postgresql/$from/main/ \
-D /var/lib/postgresql/$to/main/
for s in $from $to
do
rm -f /var/lib/postgresql/$s/main/*.conf
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment