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
, sm_devices
and sm_device_models
tables:
mysqldump -u root -p --single-transaction sambackend users sm_devices sm_device_models > 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
Loading the old database content into the new one
First push the file into the newer instance of the database container: