Database is Locked

I have several instances of Duplicati Failing to backup. Spanning Windows and Mac OS. I have less access to the Mac systems so I am focusing on the Windows systems at the moment. For clarification I have several instances working perfectly but some aren’t. They all backup over SFTP.

When attempting we get the message that the database is locked.

Sep 28, 2019 10:54 AM: Failed to read local db C:\Users\Charles\AppData\Local\Duplicati\RKUEFBLUFN.sqlite, error: Unable to determine database format: database is locked database is locked
{“ClassName”:“Duplicati.Library.Interface.UserInformationException”,“Message”:“Unable to determine database format: database is locked\r\ndatabase is locked”,“Data”:null,“InnerException”:{“errorCode”:“Busy”,“ClassName”:“System.Data.SQLite.SQLiteException”,“Message”:“database is locked\r\ndatabase is locked”,“Data”:null,“InnerException”:null,“HelpURL”:null,“StackTraceString”:" at System.Data.SQLite.SQLite3.Prepare(SQLiteConnection cnn, String strSql, SQLiteStatement previous, UInt32 timeoutMS, String& strRemain)\r\n at System.Data.SQLite.SQLiteCommand.BuildNextCommand()\r\n at System.Data.SQLite.SQLiteDataReader.NextResult()\r\n at System.Data.SQLite.SQLiteDataReader…ctor(SQLiteCommand cmd, CommandBehavior behave)\r\n at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)\r\n at System.Data.SQLite.SQLiteCommand.ExecuteScalar(CommandBehavior behavior)\r\n at Duplicati.Library.SQLiteHelper.DatabaseUpgrader.UpgradeDatabase(IDbConnection connection, String sourcefile, String schema, IList1 versions)","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":"8\nPrepare\nSystem.Data.SQLite, Version=1.0.105.2, Culture=neutral, PublicKeyToken=db937bc2d44ff139\nSystem.Data.SQLite.SQLite3\nSystem.Data.SQLite.SQLiteStatement Prepare(System.Data.SQLite.SQLiteConnection, System.String, System.Data.SQLite.SQLiteStatement, UInt32, System.String ByRef)","HResult":-2147467259,"Source":"System.Data.SQLite","WatsonBuckets":null},"HelpURL":null,"StackTraceString":" at Duplicati.Library.SQLiteHelper.DatabaseUpgrader.UpgradeDatabase(IDbConnection connection, String sourcefile, String schema, IList1 versions)\r\n at Duplicati.Library.SQLiteHelper.DatabaseUpgrader.UpgradeDatabase(IDbConnection connection, String sourcefile, Type eltype)\r\n at Duplicati.Library.Main.Database.LocalDatabase.CreateConnection(String path)\r\n at Duplicati.Library.Main.Operation.RepairHandler.Run(IFilter filter)",“RemoteStackTraceString”:null,“RemoteStackIndex”:0,“ExceptionMethod”:“8\nUpgradeDatabase\nSQLiteHelper, Version=2.0.4.23, Culture=neutral, PublicKeyToken=null\nDuplicati.Library.SQLiteHelper.DatabaseUpgrader\nVoid UpgradeDatabase(System.Data.IDbConnection, System.String, System.String, System.Collections.Generic.IList`1[System.String])”,“HResult”:-2146233088,“Source”:“SQLiteHelper”,“WatsonBuckets”:null}

Please let me know what you want. I can turn up logging if told how. Thanks

That database is being active during the backup because Duplicati records data about the job that is running. There is no point in including it in the backup set of the same backup job it (=the database) keeps record of.

Thanks please confirm I understand your response correctly. It is hitting this database lock error because the backup job is trying to backup the database.

I can see how this is possible as I include C:\Users in the backup job. However, I have the following exclusions.
-CloudStation
-AppData
-Users\Default
-Users\Administrator
-\Users\defaultuser

That AppData should exclude anything that has AppData in its full path. Which should include C:\Users\Charles\AppData\Local\Duplicati\RKUEFBLUFN.sqlite. Or am I missing something?

If you mean the environment APPDATA here, it refers to C:\Users\Charles\AppData\Roaming, whereas the path mentioned in the error message is C:\Users\Charles\AppData\Local, which is referred to by environment variable LOCALAPPDATA.

C:\Users is a bit too much. You should only include your home directory (and I also include my personal APPDATA). You might have a good reason to also back up Duplicati’s local databases, but preferably not in the same backup set. For that topic you find discussion here somewhere.

So I had it set to C:\Users and I agree that is fairly broad. But I thought it simpler for my family’s many computers than specifying each user on each PC independently. The I also had an exclusion set for “Excluding Directories whose name contain” AppData. I assumed that would include Everything under C:\Users\Charles|AppData and therefore exclude the local sub directory. Also if I change the backup path to C:\Users\Charles That would still include the AppData Directory and database wouldn’t it? I am going to try specifying C:\users\Charles as well as moving the database to another directory that shouldn’t be backed up. I will post the results here.

Now, there are so many aspects here that need commenting that I am out of my depth. I hope someone else will have a better chance.

As an update to close this out Moving the database from its default location under app data to C:\databases (a directory I created) seems to have solved the problem here. I Really don’t understand why my way stopped working (the last successful backup of the pc was back in April) But it use to work and it does still work on other PCs. So I am at a loss. In any case. This was solved by moving the database.