Database is locked while doing a restore

Hi,
I’m currently trying to do a restore of a directory.
I currently have two backup locations one in a local enviroment and another one on the cloud.

When I try to restore my data, I get the error message database is locked for both locations

code = Busy (5), message = System.Data.SQLite.SQLiteException (0x800007AF): database is locked
database is locked
   at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
   at System.Data.SQLite.SQLiteDataReader.NextResult()
   at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
   at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
   at Duplicati.Library.Main.Database.ExtensionMethods.ExecuteScalarInt64(IDbCommand self, Boolean writeLog, String cmd, Int64 defaultvalue, Object[] values)
   at Duplicati.Library.Main.Database.ExtensionMethods.ExecuteScalarInt64(IDbCommand self, String cmd, Int64 defaultvalue, Object[] values)
   at Duplicati.Library.Main.Database.LocalDatabase..ctor(IDbConnection connection, String operation)
   at Duplicati.Library.Main.Database.LocalDatabase..ctor(String path, String operation, Boolean shouldclose)
   at Duplicati.Library.Main.Database.LocalListDatabase..ctor(String path)
   at Duplicati.Library.Main.Operation.ListFilesHandler.Run(IEnumerable`1 filterstrings, IFilter compositefilter)
   at Duplicati.Library.Main.Controller.<>c__DisplayClass24_0.<List>b__0(ListResults result)
   at Duplicati.Library.Main.Controller.RunAction[T](T result, String[]& paths, IFilter& filter, Action`1 method)
   at Duplicati.Library.Main.Controller.RunAction[T](T result, IFilter& filter, Action`1 method)
   at Duplicati.Library.Main.Controller.List(IEnumerable`1 filterstrings, IFilter filter)
   at Duplicati.Server.Runner.Run(IRunnerData data, Boolean fromQueue)

I’m currently using the version Duplicati - 2.1.0.5_stable_2025-03-04

Hi @Matteo_Gofi, welcome to the forum :waving_hand:

This issue has been reported before, and it looks like it happens mostly on Windows.
The problem seems to be that the listing operation that is done before the restore can be extremely slow and sometimes this causes it to lock the database, so it is locked when the restore starts. This only happens if there is a large number of versions and a large number of files.

The best workaround I know of is:

  • Restart Duplicati
  • Go through the restore wizard, but don’t click “Restore”
  • Wait 60s
  • Click “Restore”

The list call has been fixed in the latest Canary build, and presumably also fixes the locking issue.