barcus/bareos

Migrate to Postgres

Closed this issue · 7 comments

I'm trying to migrate to Postgres from the MariaDB install. I've had to install the bareos-database-postgres package inside of the bareos-dir container. I've got another postgres SQL container running and it's pingable from the bareos-dir container. I'm having issues with trying to run the postgres DB creation scripts. I'm seeing:

root@165ff887ce6b:/usr/lib/bareos/scripts# ./create_bareos_database
Creating mysql database
The MySQL database backend is deprecated. Please use PostgreSQL instead.
Creating of bareos database failed.

I'm not sure if this is because when I installed the postgres package that version 12 was installed. I'm not sure if there is a transitional docker container that needs to be created to assist with this migration. Any thoughts or insights would be appreciated. Thanks!

I did not create transitional docker container for that and i'm not sure it exists.
Did you check this page from official Bareos docs to migrate your catalog ?

I've never played with this upgrade process, let me know about it please!
Could be usefull for rookie to manage this upgrade using a temporary docker-compose file or something like that.

root@165ff887ce6b:/usr/lib/bareos/scripts# ./create_bareos_database
Creating mysql database
The MySQL database backend is deprecated. Please use PostgreSQL instead.
Creating of bareos database failed.

create_bareos_database script use /usr/lib/bareos/scripts/bareos-config-lib.sh which looks inside bareos configuration file to identify the database type to init/update.
It means that you current catalog configuration is mysql.

So I was able to get this working. I was running v19. I changed my Docker Compose to v20 MySQL. I then exec'd into the container and did an apt install of the bareos-database-postgresql package. This also installed postgresql client 12. I stopped the director service. I created another Catalog.conf file that contained the postgresql information. I then ran the dbcopy script with the switches "--user postgres --database bareos-db" (bareos-db is the postgres 9.3 container I have). After it was done, I finished running through Bareos documentation:

  • Removed the old Catalog.conf MySQL file leaving the new PostgreSQL catalog file.
  • Renamed the new PostgreSQL catalog file to be the same name as the old file.

I then exited the container and modified my compose file to move to the 20-ubuntu container (which is your PostgreSQL default container) along with 20-ubuntu for File Daemon and WebUI. I stopped and deleted the containers and pulled the new containers. The containers came up on 20 PostgreSQL and worked successfully.

I then tried to upgrade to v21 and the Director container would keep restarting. It was giving me an error regarding database versions. I verified I had the config for DB_INIT and DB_UPGRADE both set to TRUE in my compose file, but no matter what I did, Director wouldn't start. I had to finally copy the contents of the /var/lib/bareos/scripts folder to my postgres container. I ran the tables upgrade script there (using --user postgres --database bareos-db) and that successfully upgraded my DB. I then was able to run Bareos v21 Director.

Thanks a lot for your feedback, I finaly tried to upgrade a MySQL database to PostgreSQL.
I used bareos_dbcopy tool as recommended in Bareos documentation, without any trouble finally
A new docker image is available for that and a docker-compose file as well. (barcus/bareos-db-migration)
It requires to mount the old MySQL db as a volume (updated to Bareos v20) and it creates new PostreSQL db if it does not exist
I tried with a fresh ubuntu-mysql-bareosv19, then i updated to Bareos v20 using ubuntu-mysql-bareosv20 and then i use the new docker-compose file to migrate to PostgreSQL.
Finaly i ran ubuntu-pgsql-bareosv21 with DB_UPDATE=true, everything worked like a charms !

i'm gonna update the readme soon :)

I really appreciate the work!