[Support Request]: Restoring database in Docker #2457

Closed
opened 2026-02-05 04:12:36 +03:00 by OVERLORD · 9 comments
Owner

Originally created by @pcapiod on GitHub (Oct 26, 2021).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Hi, the issue I am facing is related to a transfer from a docker setup with a bare-metal database (Mariadb) to a full docker setup (Mariadb).
The export of the database was done using mysqldump to an .sql file.
When importing the .sql file to the new database, I could see all the shelves/books and pages I have created with the good users in the database tables. However when I want to login using my previous credentials, I get "An Unknown error occured". I have tried different credentials (either different email or password) which I ended getting "wrong credentials" (that makes sense).
To restore the database, this is what I did:

  • Run the docker-compose file docker-compose up -d
  • Enter the container docker exec -it bookstack_db bash
  • Import the database mysql -u bookstack -p bookstackapp < bookstack_backup.sql
  • Restart the docker container (there was no apparent error in the logs)
  • Login

If you need more information, please, let me know.

Exact BookStack Version

v21.08.3-ls161

Log Content

No response

PHP Version

No response

Hosting Environment

Arcolinux, Kernel 5.10LTS, Gnome desktop, installed with a docker container (linuxserver), Mariadb database.

Originally created by @pcapiod on GitHub (Oct 26, 2021). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario Hi, the issue I am facing is related to a transfer from a docker setup with a bare-metal database (Mariadb) to a full docker setup (Mariadb). The export of the database was done using mysqldump to an .sql file. When importing the .sql file to the new database, I could see all the shelves/books and pages I have created with the good users in the database tables. However when I want to login using my previous credentials, I get "An Unknown error occured". I have tried different credentials (either different email or password) which I ended getting "wrong credentials" (that makes sense). To restore the database, this is what I did: - Run the docker-compose file `docker-compose up -d` - Enter the container `docker exec -it bookstack_db bash` - Import the database `mysql -u bookstack -p bookstackapp < bookstack_backup.sql` - Restart the docker container (there was no apparent error in the logs) - Login If you need more information, please, let me know. ### Exact BookStack Version v21.08.3-ls161 ### Log Content _No response_ ### PHP Version _No response_ ### Hosting Environment Arcolinux, Kernel 5.10LTS, Gnome desktop, installed with a docker container (linuxserver), Mariadb database.
OVERLORD added the 🐕 Support label 2026-02-05 04:12:36 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Oct 26, 2021):

Hi @pcapiod,

Did you restart both containers (Database and bookstack) to allow the bookstack container to re-run any pending migrations?

Otherwise, any An Unknown error occured messages are logged to a log file. I think the linuxserver.io image puts this log at the /config/www/laravel.log` path with you'll likely have mounted as a volume.

@ssddanbrown commented on GitHub (Oct 26, 2021): Hi @pcapiod, Did you restart both containers (Database and bookstack) to allow the bookstack container to re-run any pending migrations? Otherwise, any `An Unknown error occured` messages are logged to a log file. I think the linuxserver.io image puts this log at the /config/www/laravel.log` path with you'll likely have mounted as a volume.
Author
Owner

@galeido commented on GitHub (Oct 26, 2021):

Moi,

Huomiseen!

--
Pekka Leppänen
Security Researcher, CEO
E // @.***
W // https://galeido.com

 The content of this email is confidential and intended for the
 recipient specified in message only. It is strictly forbidden to share
 any part of this message with any third party, without a written
 consent of the sender. If you received this message by mistake, please
 reply to this message and follow with its deletion, so that we can
 ensure such a mistake does not occur in the future.

------ Original Message ------
From: "Dan Brown" @.>
To: "BookStackApp/BookStack" @.
>
Cc: "Subscribed" @.***>
Sent: 26/10/2021 15.42.24
Subject: Re: [BookStackApp/BookStack] [Support Request]: Restoring
database in Docker (Issue #3009)

Hi @pcapiod https://github.com/pcapiod,

Did you restart both containers (Database and bookstack) to allow the
bookstack container to re-run any pending migrations?

Otherwise, any An Unknown error occured messages are logged to a log
file. I think the linuxserver.io image puts this log at the
/config/www/laravel.log` path with you'll likely have mounted as a
volume.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/BookStackApp/BookStack/issues/3009#issuecomment-951900233,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ADWBXZBV6FGBRRN4VX26VF3UI2V4BANCNFSM5GXVTMRA.
Triage notifications on the go with GitHub Mobile for iOS
https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675
or Android
https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

@galeido commented on GitHub (Oct 26, 2021): Moi, Huomiseen! -- Pekka Leppänen Security Researcher, CEO E // ***@***.*** W // https://galeido.com The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to share any part of this message with any third party, without a written consent of the sender. If you received this message by mistake, please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future. ------ Original Message ------ From: "Dan Brown" ***@***.***> To: "BookStackApp/BookStack" ***@***.***> Cc: "Subscribed" ***@***.***> Sent: 26/10/2021 15.42.24 Subject: Re: [BookStackApp/BookStack] [Support Request]: Restoring database in Docker (Issue #3009) > >Hi @pcapiod <https://github.com/pcapiod>, > >Did you restart both containers (Database and bookstack) to allow the >bookstack container to re-run any pending migrations? > >Otherwise, any An Unknown error occured messages are logged to a log >file. I think the linuxserver.io image puts this log at the >/config/www/laravel.log` path with you'll likely have mounted as a >volume. > >— >You are receiving this because you are subscribed to this thread. >Reply to this email directly, view it on GitHub ><https://github.com/BookStackApp/BookStack/issues/3009#issuecomment-951900233>, >or unsubscribe ><https://github.com/notifications/unsubscribe-auth/ADWBXZBV6FGBRRN4VX26VF3UI2V4BANCNFSM5GXVTMRA>. >Triage notifications on the go with GitHub Mobile for iOS ><https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> >or Android ><https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>. >
Author
Owner

@pcapiod commented on GitHub (Oct 26, 2021):

Hi @pcapiod,

Did you restart both containers (Database and bookstack) to allow the bookstack container to re-run any pending migrations?

Otherwise, any An Unknown error occured messages are logged to a log file. I think the linuxserver.io image puts this log at the /config/www/laravel.log` path with you'll likely have mounted as a volume.

Hi @ssddanbrown, thanks for the quick answer. I have indeed restarted the container. I am going to check in the log.

Best

@pcapiod commented on GitHub (Oct 26, 2021): > Hi @pcapiod, > > Did you restart both containers (Database and bookstack) to allow the bookstack container to re-run any pending migrations? > > Otherwise, any `An Unknown error occured` messages are logged to a log file. I think the linuxserver.io image puts this log at the /config/www/laravel.log` path with you'll likely have mounted as a volume. Hi @ssddanbrown, thanks for the quick answer. I have indeed restarted the container. I am going to check in the log. Best
Author
Owner

@pcapiod commented on GitHub (Oct 26, 2021):

This is what I have in the laravel.log file:

[2021-10-26 19:19:54] production.ERROR: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'favourites' already exists 
(SQL: create table `favourites` (`id` int unsigned not null auto_increment primary key, `user_id` int not null, `favouritable_id` int not null, `favouritable_type` varchar(100) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci') 
{"exception":"[object] (Illuminate\\Database\\QueryException(code: 42S01): SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'favourites' already exists 
(SQL: create table `favourites` (`id` int unsigned not null auto_increment primary key, `user_id` int not null, `favouritable_id` int not null, `favouritable_type` varchar(100) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci') 
at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669)

EDIT: formatting the code

@pcapiod commented on GitHub (Oct 26, 2021): This is what I have in the `laravel.log` file: ``` [2021-10-26 19:19:54] production.ERROR: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'favourites' already exists (SQL: create table `favourites` (`id` int unsigned not null auto_increment primary key, `user_id` int not null, `favouritable_id` int not null, `favouritable_type` varchar(100) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci') {"exception":"[object] (Illuminate\\Database\\QueryException(code: 42S01): SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'favourites' already exists (SQL: create table `favourites` (`id` int unsigned not null auto_increment primary key, `user_id` int not null, `favouritable_id` int not null, `favouritable_type` varchar(100) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci') at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669) ``` EDIT: formatting the code
Author
Owner

@ssddanbrown commented on GitHub (Oct 26, 2021):

@pcapiod That's a strange point to get an error. It could be that something else has failed.
Assuming the container name is bookstack, Could you run the following and share the output?:

docker exec -it bookstack /usr/bin/php /var/www/html/artisan migrate:status
@ssddanbrown commented on GitHub (Oct 26, 2021): @pcapiod That's a strange point to get an error. It could be that something else has failed. Assuming the container name is `bookstack`, Could you run the following and share the output?: ```bash docker exec -it bookstack /usr/bin/php /var/www/html/artisan migrate:status ```
Author
Owner

@pcapiod commented on GitHub (Oct 26, 2021):

I got all things at Yes for the table Ran?, until these lines:

...
| Yes  | 2021_03_08_215138_add_user_slug                   | 2     |
| No   | 2021_05_15_173110_create_favourites_table         |       |
| No   | 2021_06_30_173111_create_mfa_values_table         |       |
| No   | 2021_07_03_085038_add_mfa_enforced_to_roles_table |       |
| No   | 2021_08_28_161743_add_export_role_permission      |       |
+------+---------------------------------------------------+-------+
@pcapiod commented on GitHub (Oct 26, 2021): I got all things at `Yes` for the table `Ran?`, until these lines: ``` ... | Yes | 2021_03_08_215138_add_user_slug | 2 | | No | 2021_05_15_173110_create_favourites_table | | | No | 2021_06_30_173111_create_mfa_values_table | | | No | 2021_07_03_085038_add_mfa_enforced_to_roles_table | | | No | 2021_08_28_161743_add_export_role_permission | | +------+---------------------------------------------------+-------+ ```
Author
Owner

@ssddanbrown commented on GitHub (Oct 26, 2021):

@pcapiod Okay, That's good. I'd suggest the following steps:

  • Ensure you have a backup of your database.
  • Access the database container and drop the favourites table in your bookstack database.
  • Restart both containers. If an error message occurs in the logs of your bookstack container ensure you take note of the first error that occurs (On first run). Otherwise, if no errors occur, it may get through the migrations and start working hopefully.
@ssddanbrown commented on GitHub (Oct 26, 2021): @pcapiod Okay, That's good. I'd suggest the following steps: - Ensure you have a backup of your database. - Access the database container and drop the `favourites` table in your bookstack database. - Restart both containers. If an error message occurs in the logs of your bookstack container ensure you take note of the first error that occurs (On first run). Otherwise, if no errors occur, it may get through the migrations and start working hopefully.
Author
Owner

@pcapiod commented on GitHub (Oct 26, 2021):

@pcapiod Okay, That's good. I'd suggest the following steps:

* Ensure you have a backup of your database.

* Access the database container and drop the `favourites` table in your bookstack database.

* Restart both containers. If an error message occurs in the logs of your bookstack container ensure you take note of the first error that occurs (On first run). Otherwise, if no errors occur, it may get through the migrations and start working hopefully.

@ssddanbrown, It is working !

Alright so in case someone encounter the issue,

  • I entered the bookstack_db container, used mysql -u root -p bookstackapp to enter and modify database's tables.
  • I used DROP TABLE favourites;
  • I had to use DROP TABLE mfa_values (same error with that row)
  • Restarted both containers
  • Checked with docker exec -it bookstack /usr/bin/php /var/www/html/artisan migrate:status and everything was Ran
  • I could login and find my data.

Thanks for the support @ssddanbrown !

Best

@pcapiod commented on GitHub (Oct 26, 2021): > > > @pcapiod Okay, That's good. I'd suggest the following steps: > > * Ensure you have a backup of your database. > > * Access the database container and drop the `favourites` table in your bookstack database. > > * Restart both containers. If an error message occurs in the logs of your bookstack container ensure you take note of the first error that occurs (On first run). Otherwise, if no errors occur, it may get through the migrations and start working hopefully. @ssddanbrown, It is working ! Alright so in case someone encounter the issue, - I entered the bookstack_db container, used `mysql -u root -p bookstackapp` to enter and modify database's tables. - I used `DROP TABLE favourites;` - I had to use `DROP TABLE mfa_values` (same error with that row) - Restarted both containers - Checked with `docker exec -it bookstack /usr/bin/php /var/www/html/artisan migrate:status` and everything was `Ran` - I could login and find my data. Thanks for the support @ssddanbrown ! Best
Author
Owner

@ssddanbrown commented on GitHub (Oct 27, 2021):

Awesome! Glad it's working now, not sure why it was getting stuck though.

@ssddanbrown commented on GitHub (Oct 27, 2021): Awesome! Glad it's working now, not sure why it was getting stuck though.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2457