Cannot restore to fresh install #221

Closed
opened 2026-02-04 17:46:43 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @the4ndy on GitHub (Dec 12, 2016).

So I set up Bookstack with the Ubuntu 16.04 installation script. It worked well. I then used it for a week or so and then followed the backup instructions. So far so good. Now I am trying to restore it and I am running into issues.

Fresh Ubuntu 16.04 VM. Run installation script. Bookstack installs fine. I check the .env file for current bookstack mysql user password. run the mysql restore using the bookstack user. No issues there. Now the web interface says "something went wrong". Restore the files based backup. Still says something went wrong. Try and run php artisan migrate get error about permission. the .env file is from my old installation. Change the password in mysql or in the .env. Now rerun the php artisan migrate and i get the following error and is where i get stuck.

  [Illuminate\Database\QueryException]                                                                                                                                                         
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'attachments' already exists (SQL: create table `attachments` (`id` int unsigned not null auto_increment primary key, `name`  
   varchar(255) not null, `path` varchar(255) not null, `extension` varchar(20) not null, `uploaded_to` int not null, `external` tinyint(1) not null, `order` int not null, `created_by` int   
  not null, `updated_by` int not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8 collate utf8_unicode_ci)                                           
                                                                                               
  [PDOException]                                                                               
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'attachments' already exists 

For Bug Reports

PHP Version: PHP 7.0.8-0ubuntu0.16.04.3

MySQL Version: mysql Ver 14.14 Distrib 5.7.16, for Linux (x86_64) using EditLine wrapper

Expected Behavior: I was expecting to be able to restore my data from a previous install

Actual Behavior: See above

Originally created by @the4ndy on GitHub (Dec 12, 2016). So I set up Bookstack with the Ubuntu 16.04 installation script. It worked well. I then used it for a week or so and then followed the backup instructions. So far so good. Now I am trying to restore it and I am running into issues. Fresh Ubuntu 16.04 VM. Run installation script. Bookstack installs fine. I check the .env file for current bookstack mysql user password. run the mysql restore using the bookstack user. No issues there. Now the web interface says "something went wrong". Restore the files based backup. Still says something went wrong. Try and run ```php artisan migrate``` get error about permission. the .env file is from my old installation. Change the password in mysql or in the .env. Now rerun the ```php artisan migrate``` and i get the following error and is where i get stuck. ``` [Illuminate\Database\QueryException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'attachments' already exists (SQL: create table `attachments` (`id` int unsigned not null auto_increment primary key, `name` varchar(255) not null, `path` varchar(255) not null, `extension` varchar(20) not null, `uploaded_to` int not null, `external` tinyint(1) not null, `order` int not null, `created_by` int not null, `updated_by` int not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8 collate utf8_unicode_ci) [PDOException] SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'attachments' already exists ``` ### For Bug Reports PHP Version: PHP 7.0.8-0ubuntu0.16.04.3 MySQL Version: mysql Ver 14.14 Distrib 5.7.16, for Linux (x86_64) using EditLine wrapper Expected Behavior: I was expecting to be able to restore my data from a previous install Actual Behavior: See above
OVERLORD added the 🐕 Support label 2026-02-04 17:46:43 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Dec 13, 2016):

Hi @the4ndy, Sorry to hear you're having trouble with the restore.

Looking at what you've written I think I can spot the issue here. I think your backup was done on an older version of BookStack which you've restored into a new version of BookStack. The install script would have run the migrations on the latest version of BookStack thus creating the attachments table. You're restore will likely have not removed this table but kept it since the old data did not contain this table. When you've come to run migrations it's trying to create the table which has already been created by the install script.

Your best bet is to drop all tables in you BookStack database before you restore (If your SQL backup contains CREATE TABLE statements). Alternatively you may get away with just dropping the attachments table before migrating.

Let me know if I've understood this wrong or if this above solutions work.

@ssddanbrown commented on GitHub (Dec 13, 2016): Hi @the4ndy, Sorry to hear you're having trouble with the restore. Looking at what you've written I think I can spot the issue here. I think your backup was done on an older version of BookStack which you've restored into a new version of BookStack. The install script would have run the migrations on the latest version of BookStack thus creating the `attachments` table. You're restore will likely have not removed this table but kept it since the old data did not contain this table. When you've come to run migrations it's trying to create the table which has already been created by the install script. Your best bet is to drop all tables in you BookStack database before you restore (If your SQL backup contains `CREATE TABLE` statements). Alternatively you may get away with just dropping the `attachments` table before migrating. Let me know if I've understood this wrong or if this above solutions work.
Author
Owner

@ssddanbrown commented on GitHub (Jul 27, 2017):

Will close due to issue age and lack of response. If you have further issues feel free to still comment on this or create a new issue.

@ssddanbrown commented on GitHub (Jul 27, 2017): Will close due to issue age and lack of response. If you have further issues feel free to still comment on this or create a new issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#221