Shelves and Books lost suddenly #3510

Closed
opened 2026-02-05 06:56:03 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @dververis on GitHub (Feb 15, 2023).

Describe the Bug

I run bookstack v.23.01.1 in a docker container using a mysql database also in a docker container.
Suddenly without any known update from my side all entries are gone. As well shelves as book are gone, while login .which is based on database entries- works.
Looking in the database in the tables "bookshelves" and "books" the entries are still there.
Even creating new shelves and books create the appropriate entries in the db.
There is no deletion entry and the ownership also fits.

What could be the reason

Steps to Reproduce

No reproduction on other instances possible

Expected Behaviour

Listings of shelves and books available

Screenshots or Additional Context

No response

Browser Details

Chrome, Brave, Edge

Exact BookStack Version

v23.01.1

PHP Version

v. 8.1.15

Hosting Environment

OS: Debian GNU/Linux 11
Env: Docker v.20.10.12
mysql: v. Ver 15.1 Distribution: 10.6.10-MariaDB

Originally created by @dververis on GitHub (Feb 15, 2023). ### Describe the Bug I run bookstack v.23.01.1 in a docker container using a mysql database also in a docker container. Suddenly without any known update from my side all entries are gone. As well shelves as book are gone, while login .which is based on database entries- works. Looking in the database in the tables "bookshelves" and "books" the entries are still there. Even creating new shelves and books create the appropriate entries in the db. There is no deletion entry and the ownership also fits. What could be the reason ### Steps to Reproduce No reproduction on other instances possible ### Expected Behaviour Listings of shelves and books available ### Screenshots or Additional Context _No response_ ### Browser Details Chrome, Brave, Edge ### Exact BookStack Version v23.01.1 ### PHP Version v. 8.1.15 ### Hosting Environment OS: Debian GNU/Linux 11 Env: Docker v.20.10.12 mysql: v. Ver 15.1 Distribution: 10.6.10-MariaDB
OVERLORD added the 🐛 Bug label 2026-02-05 06:56:03 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Feb 15, 2023):

Hi @dververis,
Could you confirm what container you're using and the full bookstack container log output you see when restarting the container?

@ssddanbrown commented on GitHub (Feb 15, 2023): Hi @dververis, Could you confirm what container you're using and the full bookstack container log output you see when restarting the container?
Author
Owner

@dververis commented on GitHub (Feb 15, 2023):

Hi @ssddanbrown,
Thank you very much for your quick reply. I am using this image https://hub.docker.com/r/linuxserver/bookstack from linuxserver.io.
The output at restarting is following -and excuse me for not providing it earlier :)

[migrations] started
[migrations] 01-nginx-site-confs-default: skipped
[migrations] 02-default-location: skipped
[migrations] done
-------------------------------------
          _         ()
         | |  ___   _    __
         | | / __| | |  /  \
         | | \__ \ | | | () |
         |_| |___/ |_|  \__/
Brought to you by linuxserver.io
-------------------------------------
To support LSIO projects visit:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------
User uid:    1000
User gid:    1000
-------------------------------------
using keys found in /config/keys
App Key found - setting variable for seds
Running config - DB_HOST set
Waiting for DB to be available
Migrating: 2023_01_24_104625_refactor_joint_permissions_storage
   Illuminate\Database\QueryException 
  SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'status' (SQL: alter table `joint_permissions` add `status` tinyint unsigned not null, add `owner_id` int unsigned null)
  at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
    708▕         // If an exception occurs when attempting to run a query, we'll format the error
    709▕         // message to include the bindings with SQL, which will make this exception a
    710▕         // lot more helpful to the developer instead of just the database's errors.
    711▕         catch (Exception $e) {
  ➜ 712▕             throw new QueryException(
    713▕                 $query, $this->prepareBindings($bindings), $e
    714▕             );
    715▕         }
    716▕     }
      +9 vendor frames 
  10  /app/www/database/migrations/2023_01_24_104625_refactor_joint_permissions_storage.php:28
      Illuminate\Support\Facades\Facade::__callStatic()
      +22 vendor frames 
  33  /app/www/artisan:37
      Illuminate\Foundation\Console\Kernel::handle()
[custom-init] No custom files found, skipping...
[ls.io-init] done.

There seems to be an issue with a database migration. Didn't see that before. Sorry

What could be the issue?

@dververis commented on GitHub (Feb 15, 2023): Hi @ssddanbrown, Thank you very much for your quick reply. I am using this image https://hub.docker.com/r/linuxserver/bookstack from linuxserver.io. The output at restarting is following -and excuse me for not providing it earlier :) <details> ``` [migrations] started [migrations] 01-nginx-site-confs-default: skipped [migrations] 02-default-location: skipped [migrations] done ------------------------------------- _ () | | ___ _ __ | | / __| | | / \ | | \__ \ | | | () | |_| |___/ |_| \__/ Brought to you by linuxserver.io ------------------------------------- To support LSIO projects visit: https://www.linuxserver.io/donate/ ------------------------------------- GID/UID ------------------------------------- User uid: 1000 User gid: 1000 ------------------------------------- using keys found in /config/keys App Key found - setting variable for seds Running config - DB_HOST set Waiting for DB to be available Migrating: 2023_01_24_104625_refactor_joint_permissions_storage Illuminate\Database\QueryException SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'status' (SQL: alter table `joint_permissions` add `status` tinyint unsigned not null, add `owner_id` int unsigned null) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:712 708▕ // If an exception occurs when attempting to run a query, we'll format the error 709▕ // message to include the bindings with SQL, which will make this exception a 710▕ // lot more helpful to the developer instead of just the database's errors. 711▕ catch (Exception $e) { ➜ 712▕ throw new QueryException( 713▕ $query, $this->prepareBindings($bindings), $e 714▕ ); 715▕ } 716▕ } +9 vendor frames 10 /app/www/database/migrations/2023_01_24_104625_refactor_joint_permissions_storage.php:28 Illuminate\Support\Facades\Facade::__callStatic() +22 vendor frames 33 /app/www/artisan:37 Illuminate\Foundation\Console\Kernel::handle() [custom-init] No custom files found, skipping... [ls.io-init] done. ``` </details> There seems to be an issue with a database migration. Didn't see that before. Sorry What could be the issue?
Author
Owner

@ssddanbrown commented on GitHub (Feb 16, 2023):

Thanks for providing that info.
Unfortunately it's hard to know the fundamental issue on migration re-run, since the error would be different after first run. My guess is that either the original migration attempted failed for some reason or was cancelled. That migration could have taken a while, as was noticed in our update notices for the 23.01 release.

  • Out of interest, How are updates (for the bookstack container) done in your environment? An automated system or manual handling?
  • How comfortable are you with accessing the database and running SQL commands? Next steps will be tailored accordingly.
@ssddanbrown commented on GitHub (Feb 16, 2023): Thanks for providing that info. Unfortunately it's hard to know the fundamental issue on migration re-run, since the error would be different after first run. My guess is that either the original migration attempted failed for some reason or was cancelled. That migration could have taken a while, as was noticed in our update notices for the 23.01 release. - Out of interest, How are updates (for the bookstack container) done in your environment? An automated system or manual handling? - How comfortable are you with accessing the database and running SQL commands? Next steps will be tailored accordingly.
Author
Owner

@dververis commented on GitHub (Feb 16, 2023):

You' re welcome @ssddanbrown
Hope this answers help

  • Updates are done using watchtower
  • I can access the database as well by using phpmyadmin and with command line
@dververis commented on GitHub (Feb 16, 2023): You' re welcome @ssddanbrown Hope this answers help - Updates are done using watchtower - I can access the database as well by using phpmyadmin and with command line
Author
Owner

@ssddanbrown commented on GitHub (Feb 16, 2023):

Thanks @dververis!

Updates are done using watchtower

Interesting, have been getting similiar things from other docker users, thinking watchtower could be a commonality.

I can access the database as well by using phpmyadmin and with command line

Awesome.
Before anything, stop the bookstack container and ensure you have backups/snapshots of everything.

  • Check that the joint_permissions table has both a status and owner_id column. Stop here and report back if the table does not have both of those columns.
  • Run the following sql statement against your bookstack database:
insert into migrations (migration, batch) select '2023_01_24_104625_refactor_joint_permissions_storage', max(batch) + 1 from migrations
  • If that's successful, restart the bookstack container. Be sure to check and record any errors on first boot. It should hopefully successfully complete an additional migration.
  • You'll then need to rebuild permissions manually. To do this, you'd run the bookstack regen permissions command via the BookStack container, which will look something like this:
# Where 'bookstack' in the below is the bookstack container name.
docker exec -it bookstack php /app/www/artisan bookstack:regenerate-permissions

After that you should be good to go.

@ssddanbrown commented on GitHub (Feb 16, 2023): Thanks @dververis! > Updates are done using watchtower Interesting, have been getting similiar things from other docker users, thinking watchtower could be a commonality. > I can access the database as well by using phpmyadmin and with command line Awesome. Before anything, stop the bookstack container and ensure you have backups/snapshots of everything. - Check that the `joint_permissions` table has both a `status` and `owner_id` column. Stop here and report back if the table does not have both of those columns. - Run the following sql statement against your bookstack database: ```sql insert into migrations (migration, batch) select '2023_01_24_104625_refactor_joint_permissions_storage', max(batch) + 1 from migrations ``` - If that's successful, restart the bookstack container. Be sure to check and record any errors on first boot. It should hopefully successfully complete an additional migration. - You'll then need to rebuild permissions manually. To do this, you'd run the [bookstack regen permissions command](https://www.bookstackapp.com/docs/admin/commands/#regenerate-access-permissions) via the BookStack container, which will look something like this: ```bash # Where 'bookstack' in the below is the bookstack container name. docker exec -it bookstack php /app/www/artisan bookstack:regenerate-permissions ``` After that you should be good to go.
Author
Owner

@dververis commented on GitHub (Feb 16, 2023):

@ssddanbrown 1000 Thanks!! 🙏🏻
It worked fine. Everything is back again. 👍

Thank you so much. Great application you have created!!!

@dververis commented on GitHub (Feb 16, 2023): @ssddanbrown 1000 Thanks!! 🙏🏻 It worked fine. Everything is back again. 👍 Thank you so much. Great application you have created!!!
Author
Owner

@ssddanbrown commented on GitHub (Feb 16, 2023):

Great to hear you're back up and running! And thanks!

Will keep an ear out and continue to question watchtower usage when I hear about database problems.
Possibly the watchtower timeout is interrupting the update process before it can complete.

Will therefore close this off.

@ssddanbrown commented on GitHub (Feb 16, 2023): Great to hear you're back up and running! And thanks! Will keep an ear out and continue to question watchtower usage when I hear about database problems. Possibly the [watchtower timeout](https://containrrr.dev/watchtower/arguments/#wait_until_timeout) is interrupting the update process before it can complete. Will therefore close this off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3510