Identify a book from attachment in filesystem #5258

Closed
opened 2026-02-05 09:51:57 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @towerplease on GitHub (Apr 11, 2025).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Hey there,
i am currently cleaning my bookstack instance by uploading large videofiles to an external service and embed the video into the book. I want to cleanup the diskspace used by bookstack as i am exceeding nearly 100 GB, which most part is from large videos i have directly uploaded.

So, after cleaning about 100 pages, i still see multiple large mp4-files on the filesystem:

Image

Is there a way, to identify, search or list books with large attachments, or at least like *.mp4-attachments?

Thanks in advance!
Regards

Exact BookStack Version

25.02.2

Log Content

No response

Hosting Environment

Self hosted on ubuntu 24.04 server with docker-image "image: lscr.io/linuxserver/bookstack" and mariadb.

Originally created by @towerplease on GitHub (Apr 11, 2025). ### Attempted Debugging - [x] I have read the debugging page ### Searched GitHub Issues - [x] I have searched GitHub for the issue. ### Describe the Scenario Hey there, i am currently cleaning my bookstack instance by uploading large videofiles to an external service and embed the video into the book. I want to cleanup the diskspace used by bookstack as i am exceeding nearly 100 GB, which most part is from large videos i have directly uploaded. So, after cleaning about 100 pages, i still see multiple large mp4-files on the filesystem: ![Image](https://github.com/user-attachments/assets/5a2b4640-4d84-4a0b-83fc-85c0a22f8ce8) Is there a way, to identify, search or list books with large attachments, or at least like *.mp4-attachments? Thanks in advance! Regards ### Exact BookStack Version 25.02.2 ### Log Content _No response_ ### Hosting Environment Self hosted on ubuntu 24.04 server with docker-image "image: lscr.io/linuxserver/bookstack" and mariadb.
OVERLORD added the 🐕 Support label 2026-02-05 09:51:57 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Apr 12, 2025):

Hi @towerplease,

So, after cleaning about 100 pages, i still see multiple large mp4-files on the filesystem:

It's worth noting that the attachments will not be deleted until the pages are deleted from the recycle bin, just in case you expected fewer attachments after doing this cleaning.

Is there a way, to identify, search or list books with large attachments, or at least like *.mp4-attachments?

No, no built-in way to back-trace attachment files right now.
If it helps, here's a cheeky command you can run in the BookStack instance to list attachment paths alongside page links (for the page the attachment is uploaded to):

php artisan tinker --execute='echo Attachment::query()->where("external", "=", false)->get()->map(fn($a) => "{$a->path}, " . url("/link/" . $a->uploaded_to))->join("\n");'

# The above is a general example when running via a normal install.
# To run via a docker container, the command may look something like:
docker exec -it bookstack php /app/www/artisan tinker --execute='echo Attachment::query()->where("external", "=", false)->get()->map(fn($a) => "{$a->path}, " . url("/link/" . $a->uploaded_to))->join("\n");'
@ssddanbrown commented on GitHub (Apr 12, 2025): Hi @towerplease, > So, after cleaning about 100 pages, i still see multiple large mp4-files on the filesystem: It's worth noting that the attachments will not be deleted until the pages are deleted from the recycle bin, just in case you expected fewer attachments after doing this cleaning. > Is there a way, to identify, search or list books with large attachments, or at least like *.mp4-attachments? No, no built-in way to back-trace attachment files right now. If it helps, here's a cheeky command you can run in the BookStack instance to list attachment paths alongside page links (for the page the attachment is uploaded to): ```bash php artisan tinker --execute='echo Attachment::query()->where("external", "=", false)->get()->map(fn($a) => "{$a->path}, " . url("/link/" . $a->uploaded_to))->join("\n");' # The above is a general example when running via a normal install. # To run via a docker container, the command may look something like: docker exec -it bookstack php /app/www/artisan tinker --execute='echo Attachment::query()->where("external", "=", false)->get()->map(fn($a) => "{$a->path}, " . url("/link/" . $a->uploaded_to))->join("\n");' ```
Author
Owner

@towerplease commented on GitHub (Apr 12, 2025):

Hi @ssddanbrown
Thank you very much for this help. I tried this and found the reference i needed to cleanup the rest of the pages :)

Otherwise, i want to mention, i could search for the books in the time created from the filesystem folder name (2022-03-Mar) sadly at this time, i created a lot of books, so it was hard to identify, with your command its propably easier.

Also thank you for your note regarding page-deletion. But, in my case, i just edited the page and replaced the attachment-link with the embedded link from the external media-source. The attachment file i deleted in the attachment-section, so the attachment is removed from filesystem immediatly.

All in all, i am finished now and cleaned up around 15 GB of video-files which are now hosted externally ;)

Thank you again, issue resolved

@towerplease commented on GitHub (Apr 12, 2025): Hi @ssddanbrown Thank you very much for this help. I tried this and found the reference i needed to cleanup the rest of the pages :) Otherwise, i want to mention, i could search for the books in the time created from the filesystem folder name (2022-03-Mar) sadly at this time, i created a lot of books, so it was hard to identify, with your command its propably easier. Also thank you for your note regarding page-deletion. But, in my case, i just edited the page and replaced the attachment-link with the embedded link from the external media-source. The attachment file i deleted in the attachment-section, so the attachment is removed from filesystem immediatly. All in all, i am finished now and cleaned up around 15 GB of video-files which are now hosted externally ;) Thank you again, issue resolved
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5258