Content
Migration OP 7.3.2 (Docker) to 7.4.2 (Packaged)
Added by Johann Letzel about 1 month ago
Hi !
We want to migrate our OP running on Docker to a "real" machine.
Source:
OP 7.3.2 with PostgreSQL 9.4 based on Docker
Target:
OP 7.4.2 with PostgreSQL 9.6 installed on CentOS 8 via yum
According to this
https://www.openproject.org/operations/backup/migrating-packaged-installation-environment/
we created a backup from the Docker OP and tried to restore it to the new environment.
But we get the error
pg_restore: [Archivierer (DB)] Fehler in Phase PROCESSING TOC: pg_restore: [Archivierer (DB)] Fehler in Inhaltsverzeichniseintrag 2743; 1259 16392 INDEX unique_schema_migrations openproject pg_restore: [Archivierer (DB)] could not execute query: FEHLER: Index »unique_schema_migrations« existiert nicht Die Anweisung war: DROP INDEX public.unique_schema_migrations;
What is the problem here ? Is it PostgreSQL 9.6 ?
Thanks in advance.
Regards.
Johann Letzel
Replies (3)
RE: Migration OP 7.3.2 (Docker) to 7.4.2 (Packaged)
-
Added by David Camilo 22 days ago
Hello Johann,
After trying many times to move my docker container from my desktop to the VPS, that i couldn't finally do, I decide to migrate my Docker OP 7.3.2 to Packaged OP 7.4.2. And it finally works.
I have followed these steps
1 Create a dump for the database inside the container
$ docker exec -it openproject /bin/bash
(here is were you helped me to get inside the container. Thanks again)
$ su postgres
postgres$ pg_dump -Fc openproject > /tmp/openprojectdb.dump
(inside /tmp postgres user can write)
2 Copy the dump to my server using scp command
3 Install on the server (Ubuntu 16.04) OpenProject Packaged installation following the steps on https://www.openproject.org/download-and-installation/
4 I Stoped before openproject configure
5 Install PostgreSQL 9.4 following the steps on https://www.openproject.org/development/setting-up-development-environment/ for configuring PostgreSQL database.
6 Restore the dump on the server
$su postgres
postgres$ dropdb openproject
postgres$ createdb -T template0 -O openproject openproject
postgres$ \q
$ pg_restore -d openproject /var/backups/openprojectdb.dump
7 Upgrade Postgres from 9.4 to 9.6 following https://www.openproject.org/operations/upgrading/openproject-postgresql-migration-guide-9-6/
8 manual configuration for the PostgreSQL database
$ openproject config:set DATABASE_URL=postgresql://openproject:"password"@127.0.0.1:5432/openproject
9 Openproject configuration wizard skipping MySQL configuration
$ sudo openporject configure
It's working form me, I hope it helps you
Regards
David.
RE: Migration OP 7.3.2 (Docker) to 7.4.2 (Packaged)
-
Added by Johann Letzel 6 days ago
Hi !
Thanks for that finally we were able to do the trick. I will try to describe it briefely. You use these method at own risk !
Prequsites¶
Source OP
Docker Container with OpenProject 7.3.2 and PostgreSQL 9.4
Target OP
CentOS with "fresh" and fully configured OpenProject 7.4.2 with PostgreSQL 9.6
Create data dump¶
- Stop Docker container
- Execute
docker run --rm --volumes-from op_system -v /home/[Host user]:/backup ubuntu bash -c "tar -cvzf /backup/opsystem.tar.gz /var/lib/postgresql/9.4/main /var/db/openproject"
- On success you got a
opsystem.tar.gz
in your home directory
Migrate data from PostgreSQL 9.4 to 9.6¶
- Create a new container for migration
docker create --name pg_migrate ubuntu:latest /bin/bash -c "sleep 9999999"
- Start container with
docker start pg_migrate
- Connect to container with
docker exec -it pg_migrate /bin/bash
- install additional stuff
apt-get update apt-get install software-properties-common apt-get install wget add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main" wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - apt-get update apt-get install postgresql-9.4 apt-get install postgresql-9.6
- Check if both PG clusters are inactive with
pg_lsclusters
- Exit container session with
exit
- Copy the dump from host into container with
docker cp opsystem.tar.gz pg_migrate:/
- Connect to container with
docker exec -it pg_migrate /bin/bash
- Drop old PG 9.4 cluster with
pg_dropcluster 9.4 main --stop
- Extract dump with
cd / tar -xvzf opsystem.tar.gz
- Correct ownership with
cd /var/lib/postgresql chown -R postgres:postgres 9.4
- Initialize 9.4 cluster with dumped data by executing
pg_createcluster 9.4 main
- After that start migration with
pg_dropcluster 9.6 main --stop pg_upgradecluster -v 9.6 9.4 main
- Start 9.6 cluster an check its tcp port
pg_ctlcluster 9.6 main start pg_lsclusters
- Create PG dump with by using the port number you retrieved
cd /usr/lib/postgresql/9.6/bin/ ./pg_dump -p [Port] -U postgres -F t openproject > /root/op96.tar
- Exit container with
exit
- Copy PG dump to host with
docker cp pg_migrate:/root/op96.tar .
- Stop migartion container with
docker stop pg_migrate
- You have now a
op96.tar
on your host
Migration to OP 7.4¶
- Copy both files
opsystem.tar.gz
andop96.tar
to new server to your home directory (e.g,/home/openproject
) - Stop existing OpenProject with
sudo systemctl stop openproject
- Drop existing OP database with (maybe PG user (with -U parameter) and password is needed)
cd /usr/pgsql-9.6/bin/ dropdb 'openproject' createdb 'openproject'
- Restore dump with (there will be one error which can be ignored)
./pg_restore -d openproject -F t ~/op96.tar
- Now extract and restore the attachments with (assumes an empty OP 7.4)
cd /home/openproject tar -xvzf opsystem.tar.gz cd var/db/openproject/files cp -r attachment /var/db/openproject/files/
- Start configuration process of OP to migrate and attach the restored database with
sudo openproject configure
- Wait for OP is coming up
Lucky ending¶
With a lot kluck you have a running OP 7.4 with you actual data
Hope this help others in future ...
Regards.
RE: Migration OP 7.3.2 (Docker) to 7.4.2 (Packaged)
-
Added by Oliver Günther 3 days ago
Hi Johann,
thanks for your elaborate steps for the migration. Can we include this guide in our migration documentation for docker-based installations for 7.4. ?
Best,
Oliver