I figured it out. I have to remove the old database and create a new one.
sudo -u gitlab-psql /opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql/ -d gitlabhq_production
drop database mattermost_production
;
create database mattermost_production
;
\q
Once that is done, the restore command works with no errors.