Introduction
Terraform Enterprise v202103-1
introduced logic to upgrade the internally-managed PostgreSQL data from PostgreSQL 9.5 to PostgreSQL 12. This change only affects proof of concept and mounted disk installations.
Use Case
Before Terraform Enterprise upgrades the PostgreSQL data from PostgreSQL 9.5 to PostgreSQL 12, a backup of the PostgreSQL 9.5 data is created to ensure data integrity in case of an error. Depending on the PostgreSQL data size, this backup can take a long time to complete and possibly lead to a timeout. Operators with a large PostgreSQL data size may want to back up the PostgreSQL data manually before upgrading to Terraform Enterprise v202103-1
so that Terraform Enterprise will skip creating a PostgreSQL backup when it attempts to upgrade the PostgreSQL data.
This backup procedure is meant to supplement, not replace, any backup procedure that an operator may have. If any operator has an existing backup procedure, that existing backup procedure should be performed in addition to the procedure detailed here.
NOTES: If the file ${backup_path}/.pg_backup_done, where the ${backup_path} is retrieved by the initial step of the procedure below, already exists, please DO NOT perform these steps. It indicates that the upgrade process has completed the backup step and the failure occurred at different phase of the upgrade. Please contact [HashiCorp Support](https://www.hashicorp.com/technical-support-services-and-policies) to request for further assistance.
Procedure
Determine the PostgreSQL data path and PostgreSQL backup path. These paths differ between proof of concept and mounted disk installations.
For proof of concept installations:
# The PostgreSQL data path.
docker_vol_pgdata="$(docker volume inspect --format='{{.Mountpoint}}' postgres)"
pgdata_path="${docker_vol_pgdata}/pgdata"
# The PostgreSQL backup path.
docker_vol_backup="$(docker volume inspect --format='{{.Mountpoint}}' postgres_backup)"
backup_path="${docker_vol_backup}/9.5"
For mounted disk installations:
# The mounted disk path. The `tr` is needed to remove the carriage return.
mounted_disk_path="$(replicatedctl app-config export --template '{{.disk_path.Value}}' | tr -d '\r')"
# The PostgreSQL data path.
pgdata_path="${mounted_disk_path}/postgres/pgdata"
# The PostgreSQL backup path.
backup_path="${mounted_disk_path}/postgres-backup/9.5"
Ensure that the ${backup_path}
exists.
mkdir ${backup_path}
Confirm that the ${pgdata_path}
and ${backup_path}
variables contain the correct paths:
echo ${pgdata_path}
echo ${backup_path}
Shut down the Terraform Enterprise application to stop writes to the PostgreSQL database.
replicatedctl app stop
Backup the PostgreSQL 9.5 data.
cp -r ${pgdata_path} ${backup_path}
Create this file to configure Terraform Enterprise to skip PostgreSQL backup creation when it attempts to upgrade the PostgreSQL data.
touch "${backup_path}/.pg_backup_done"
At this point, there should be a backup of the PostgreSQL 9.5 data at ${backup_path}
. Now, the operator can either start or upgrade to Terraform Enterprise v202103-1
.
Additional Information
Here are some related articles.