Fix images in bookstack when moved to a different IP

Just thought I would post what I did when I moved my HA to a different server and IP in regards to my bookstack setup.

After restoring the database to the new server, it worked, but all the images were broken and ran really slow. After doing some searches on-line I found the relevant commands. (Before doing the below, it would make sense to backup your database or create a snapshot via HA.)

Type: mysql —> This will take you to the MariaDB prompt.

Type: USE bookstack;

Then use the following commands to fix up all your images:

UPDATE images SET url = REPLACE( REPLACE( url, 'http://<old-ip-address>:2665', 'http://<new-ip-address>:2665'), 'http://<old-ip-address>:2665', 'http://<new-ip-address>:2665');

UPDATE pages SET html = REPLACE( REPLACE( html, 'http://<old-ip-address>:2665', 'http://<new-ip-address>:2665'), 'http://<old-ip-address>:2665', 'http://<new-ip-address>:2665');

UPDATE settings SET value = REPLACE( REPLACE( value, 'http://<old-ip-address>:2665', 'http://<new-ip-address>:2665'), 'http://<old-ip-address>:2665', 'http://<new-ip-address>:2665');

UPDATE page_revisions SET html = REPLACE( REPLACE( html, 'http://<old-ip-address>:2665', 'http://<new-ip-address>:2665'), 'http://<old-ip-address>:2665', 'http://<new-ip-address>:2665');

2 Likes

This worked like a charm after I had updated my APP_URL setting in .env and it broke every image.

Thank you!