Verified Commit 199627ca authored by anarcat's avatar anarcat
Browse files

check for prod database before dropping cluster (team#41388)

This is getting ridiculous.
parent 267a9818
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -259,14 +259,24 @@ PostgreSQL is special and needs to be upgraded manually.
        export LC_ALL=C.UTF-8 &&
        printf "about to stop and destroy cluster main on postgresql-15, press enter to continue" &&
        read _ &&
        port15=$(grep ^port /etc/postgresql/15/main/postgresql.conf  | sed 's/port.*= //;s/[[:space:]].*$//')
        if psql -P $port15 --no-align --tuples-only \
               -c "SELECT datname FROM pg_database WHERE datistemplate = false and datname != 'postgres';"  \
               | grep .; then
            echo "ERROR: database cluster 15 not empty"
        else
            pg_dropcluster --stop 15 main &&
            pg_upgradecluster -m upgrade -k 13 main &&
            for cluster in `ls /etc/postgresql/13/`; do
                mv /etc/postgresql/13/$cluster/conf.d/* /etc/postgresql/15/$cluster/conf.d/
            done
        fi

    Yes, that implies DESTROYING the *NEW* version but the point is we
    then recreate it with the old one.
    then recreate it from the old one.

    TODO: this whole procedure needs to be moved into fabric, for
    sanity.

 4. change the cluster target in the backup system, in `tor-puppet`,
    for example: