Note
If your volume already contains data from the old major version, PostgreSQL will refuse to start. In that case, create a new named volume for the new container, then restore from the dump in the next step.
6. Recreate the database user and database in the new container, then restore:
``` sh
docker exec -i postgres psql -U postgres -c "CREATE USER mmuser WITH PASSWORD 'your_password';"
docker exec -i postgres psql -U postgres -c "CREATE DATABASE mattermost OWNER mmuser;"
docker exec -i postgres pg_restore -U mmuser -d mattermost < mattermost_backup.dump
```
## After the upgrade
After upgrading PostgreSQL, run `ANALYZE VERBOSE` on the Mattermost database. This re-populates the `pg_statistic` table used by PostgreSQL to generate optimal query plans. Skipping this step can result in degraded database performance.
``` sh
sudo -u postgres psql -d mattermost -c "ANALYZE VERBOSE;"
```
Once complete, restart Mattermost:
``` sh
sudo systemctl start mattermost
```