Amadis

Secure Backend - Manual migration

It can be useful for some reasons (for instance when moving to an older 1.0.x version to a newer 1.1.x version) to manually migrate / copy the data from one database to the other. To do so only a few command lines are required.

Dumping the older database content

First connect to the older instance database container:

docker exec -it samdatabase_1.0.10 /bin/sh

Don’t forget to adapt the container name (samdatabase_1.0.10 here) to your actual setup.

Then dump the content of users, SMDevices and SMDeviceModels tables:

mysqldump -u root -p --single-transaction sambackend users SMDevices SMDeviceModels > dump.sql

You will then be prompter to enter the root password to access the database.

This will create an SQL file called dump.sql with the content of the tables.

If you added personal data into other tables simply add them at the end of the command, just before the '>' character.

Now to retrieve the file on you local machine, exit the container shell and use the following command:

docker cp database:dump.sql dump.sql

Change the table names and columns and maybe the admin password…

Some tables have been renamed when moving to the new version of the product. In particular SMDevices changed into sm_devices and SMDeviceModels changed into sm_device_models. The dump.sql file need to be updated to reflect that change. This can be done either manually using a proper file editor or with some Linux-style commands such as:

The sm_devices table contains a new smrdSecurityId column that needs to be added to the file.

Update the table creation command to the following:

The modification only consists in the addition of lines 13 and 17.

Then, for each device insertion, make sure to add a NULL value at the end.

Loading the old database content into the new one

First push the file into the newer instance of the database container:

Then load the content into the database:

Â