Skip to content

Commit

Permalink
docs: Improve Howto Migrate Mysql to Postgresql.
Browse files Browse the repository at this point in the history
- Document PostgreSQL creation scripts with dbtype. BUG #1429
- Clarify execution command sequence by reordering blocks.

Signed-off-by: Bruno Friedmann <bruno.friedmann@bareos.com>
  • Loading branch information
bruno-at-bareos committed Mar 16, 2022
1 parent e4d0350 commit e3575c9
Showing 1 changed file with 34 additions and 13 deletions.
Expand Up @@ -31,10 +31,15 @@ Prepare the new database
~~~~~~~~~~~~~~~~~~~~~~~~

Firstly, create a new |postgresql| database as described in :ref:`section-CreateDatabase`.
Add the new |postgresql| database to the current |dir| configuration,
but **do not remove** the |mysql| database from the config, yet.
Both catalog resources must be present
during the migration process.
You have to give the dbtype to the script, so the right db engine is used.

.. code-block:: shell-session
:caption: Run creating script with db type specified

su - postgres /usr/lib/bareos/scripts/create_bareos_database postgresql
su - postgres /usr/lib/bareos/scripts/make_bareos_tables postgresql
su - postgres /usr/lib/bareos/scripts/grant_bareos_privileges postgresql


Both |mysql| and |postgresql| need to have the same Bareos database scheme version,
i.e. have the schema from the identical Bareos version
Expand All @@ -46,6 +51,10 @@ i.e. have the schema from the identical Bareos version
Otherwise the |dir| will already insert data into the new |postgresql| catalog while :command:`bareos-dbcopy` will skip every table already containing data.
Add the new |postgresql| database to the current |dir| configuration,
but **do not remove** the |mysql| database from the config, yet.
Both catalog resources must be present during the migration process.
These are the catalog resources used in this example:
.. code-block:: bareosconfig
Expand Down Expand Up @@ -76,30 +85,33 @@ Run bareos-dbcopy
~~~~~~~~~~~~~~~~~
Once the databases are running you can start to copy the contents from |mysql|
to |postgresql|. Depending on the size of your database the copy process can run
up to several hours. In our tests with a database containing 160 Million rows
in the file table took about 5 hours to copy (the testsystem was equipped with SSDs).
to |postgresql|.
.. note::
Please run bareos-dbcopy as user **bareos** to avoid problems with access rights.
To start the shell as user **bareos** you can use this command:
``su -s /bin/bash - bareos``
See example below how to start the shell as user **bareos** and run dbcopy.
.. code-block:: shell-session
:caption: Run the bareos-dbcopy command
:caption: Run the bareos-dbcopy command as bareos user
# run this command as user bareos:
# Start the shell as bareos user
su -s /bin/bash - bareos
# run the command as user bareos:
bareos-dbcopy -c <path-to-bareos-config> MyCatalog MyCatalog-psql
Depending on the size of your database the copy process can run up to several hours.
In our tests with a database containing 160 Million rows in the file table took about
5 hours to copy (the testsystem was equipped with SSDs).
*bareos-dbcopy* will then examine the databases and copy the tables one by one.
The *file table* is by far the largest table and usually takes the longest time
to copy.
.. code-block:: shell-session
:caption: Example output of bareos-dbcopy
Expand Down Expand Up @@ -171,3 +183,12 @@ tasks need to be done:
* start the |dir|

The migration is now completed.

Please run bareos-dbcopy as user **bareos** to avoid problems with access rights.
To start the shell as user **bareos** you can use this command:

.. note::

Once you are ready to upgrade to :sinceVersion:`21.0.0: PostgreSQL`, **remove** the package
**bareos-database-mysql** from your installation.
We've made the upgrade process failing on purpose to avoid unattended upgrade.

0 comments on commit e3575c9

Please sign in to comment.