Skip to content

Upgrade Instructions

clonm edited this page Aug 16, 2019 · 8 revisions

Specific instructions for upgrading different containers.

There are two containers running PostgreSQL, one on server2 and one on server3. Start out by configuring some environment variables for your working environment

command argument - server2 argument - server3
export PSQL_VOL= /srv/postgresql /srv/storage/postgresql
export PSQL_NAME= pgsql postgresql
export LOG_DIR= /srv/var/log /srv/log
export PSQl_DBNAME= postgres owncloud

For both, set export VERSION= whatever version you're upgrading to, e.g. 10.

To upgrade postgresql database, follow the desired version's upgrade instructions. For existing installation,

  1. Back up the existing database by running docker exec $PSQL_NAME pg_dump -Fc -U postgres $PSQL_DBNAME > "/var/backups/$PSQL_DBNAME.$(date).pgdump" to create a backup of the entire database. You can check the name of the created file by listing files sorted by date with ls -lhat from /var/backups. The most recent file will be at the top of the list. (Note: the filename doesn't actually have to follow any particular format, I've just suggested a command that will generate unique names.)
  2. Test out the postgresql container for the new version, by running it with the following: docker run -d --restart=always --name="$PSQL_NAME-new" --hostname="$PSQL_NAME-new" -v "$LOG_DIR/$PSQL_NAME-new":"/var/log/postgresql" -v "$PSQL_VOL":"/var/lib/postgresql" clonm/postgresql:$VERSION This will start a new container running the new version. WARNING: the line above has it use the same storage directory as the existing $PSQL container. This is fine as long as the containers are running different versions, but will create a race condition if you try to run two containers with the same version of postgresql. If the database keeps crashing with lock file "postmaster.pid" contains wrong PID and The postmaster has commanded this server process to roll back the current transaction and exit, that is probably why.
  3. Import the backup file you exported to $PSQL_NAME-new:
    1. If uprgading on owncloud, you'll first have to create a user:

      docker exec -ti postgresql /bin/bash
      createuser -U postgres -DRS -PE owncloud
      createdb -U postgres -O owncloud owncloud
      

      When prompted, enter the password from /srv/storage/owncloud/config/config.php. Then exit the container with CTRL-D.

    2. (for both) from outside the container, run sudo -u $PSQL_USERNAME psql -d postgres -f "/var/backups/BACKUP_NAME". See step 1 for how to get the file name.

  4. Stop the $PSQL_NAME-new container with docker stop "$PSQL_NAME-new".
  5. Update the tag in pillars/serverX/docker/postgresql.sls to $VERSION
  6. Comment out everything but postgresql in pillars/serverX/docker/init.sls, and then follow the steps here for syncing server2.
Clone this wiki locally