Can not restore my repository backup



Please can anyone explain the correct workflow to restore my gogs backup? Unfortunately I am unable to restore my repositories. I tried several ways to restore my backups.

Git and MSSQL Server are already installed. I created the user Git_User on the database server. I created this user with full credentials, to avoid any installation errors.

I’d like to describe my problems. Unfortunately I don’t have the exact error messages at the moment because I’m in weekend now.

I have the files and my gogs.bak

When I don’t restore gogs.bak on the server I got an error, like “can’t create table”.

When I restore gogs.bak I got an error like “can’t modify table”.

I set my custom app.ini in the restore command, the login credentials are ok, because I can use them on other ways.

What can I do to get my repositories back?

Kind regards


Maybe helpful: How to backup, restore and migrate


I know this discription, but none of the advises solved my problem, each point fires an error. Next days I like to try to restore on a another machine, but I cant belive that the SQL Server is the problem.


Sorry, I am still unable to restore my repositories.

When I create an empty database „gogs“ and run the restore command:

gogs restore --from="" --config=custom/conf/app.ini

I get the following error message:

„[FATAL] Failed to import database: insert strcut: mssql: Cannot insert explicit value for identity column in table ‘user’ when IDENTITY_INSERT is set to OFF.“

When I restore the “gogs.bak” file to the server I get the same error message.

I defined the user “sa” in my app.ini, this user has the highest privileges.

What can I do?


It is always good to search the error message:


Sorry, that doesn’t fix the problem. Or my usage is not correct maybe??

What is the next step I can do?

Kind regards


I think this is an unfixed bug according to #4410. I’ll see if I can push a patch, I think the fix might be made in the source code.

I don’t know MSSQL, but from MySQL perspective, brackets ([]) around table name is strange?



Thank you very much!

The brackets are ok, for this I added the screenshot, to show the query was accepted. With the correct usage I meant the workflow of run the commands.

I look forward to the resolved problem!

Kind regards



Is there a solution in sight? I like to get my repositories with his versioning back. What can I do otherwise?

Kind regards


If manually set IDENTITY_INSERT to ON is not working, any patch from main repository won’t help because this is how the patch would likely to work.


BTW, backup and restore is database independent, so you could try to restore to another type of database (MySQL, PostgreSQL).