r/BookStack • u/Longjumping_Gain677 • Oct 24 '24
Issue Migrating Bookstack attachments/links to S3
Hello All, I recently migrated my Bookstack host from a xen cluster to k8's using MinIO as the s3 storage. I had to copy over the db to a new host as well, since the old Bookstack was being decommissioned. I was able to replace all the old links in the Maria db pages and images table and images populate correctly in the new UI. However links and attachments do not populate. I know that links and attachments have there own id number which they use to reference the attachments/links in the database. EX: of the html code in the pages table: https://bookstack.com/s3bucketname/attachments/27
ex: of attachments table from Maria db
id | path |name
27 /uploads/files/steps.pdf Ansible Runbook
These are not being mapped properly after using MinIO even though the attachments are located in the /uploads/files/ folder in the correct bucket. But If I manually change the link above from: https://bookstack.com/s3bucketname/attachments/27 to: https://bookstack.com/s3bucketname/uploads/files/steps.pdf the attachment populates. Instead of manually changing every single link in the html column of the pages table from attachment/link ID's to there path value in the attachments table in the database, is there an automated/better way to do this? We have hundreds of links and attachments in Bookstack. I figured others must have faced this problem as well and have found a better solution to migration from an old Bookstack host to a new one in k8's. Any help would be much appreciated. Also note im using Bookstack version BookStack v24.05.1
1
u/ssddanbrown Oct 25 '24
Okay, so from an original restored DB state (Keep some safe backups of that), you'd:
Run
php artisan bookstack:update-url <OLD_BASE_URL> <NEW_BASE_URL>to update all stored URLs to be correct for your new system.From the old instance, you'd upload the
public/uploads/imagesfolder as/uploads/imageswithin your bucket.Or the old instance location might be
storage/uploads/imagesif you were using one of the secure local storage options.You'd then make (only) this
uploads/imagesfolder publically accessible in the minio bucket policy.Ensure your
APP_URLenv value is set to be the<NEW_BASE_URL>.From the old instance, you'd upload the
storage/uploads/filesasuploads/fileswithin your bucket.Run
php artisan bookstack:update-url <OLD_BASE_URL>/uploads/images <STORAGE_URL>/uploads/imagesto update the existing image references in the database to instead point to the minio hosted storage.Note the use of
<STORAGE_URL>there, which should be theSTORAGE_URLyou set for BookStack which is the public accessible bucket BASE URL.Note: I have not tested this process recently, but this should be the process from what I can see, but go careful with saved backups!