DBNull Error and backup immediately fails

Hello, I am getting the following error:

Unable to determine database format: Object cannot be cast from DBNull to other types.

DBNullError

Specs:

Windows Server 2008 R2
SQL Server 2012 Standard
Duplicati version 2.0.2.1

I cannot find anybody who has had this error before. Please help.

Thanks!

Hi @Omnicef, welcome to the Dulicati forum!

Can you go into the “Show log” menu item, click on the error then copy/paste the error details into a post?

That way we can see if the details match up with the only other “DBNull” related error I’ve seen (which was on GitHub from quite a while - and many versions - ago).

HI @JonMikelV

Here ya go!

Duplicati.Library.Interface.UserInformationException: Unable to determine database format: Object cannot be cast from DBNull to other types. ---> System.InvalidCastException: Object cannot be cast from DBNull to other types.
   at System.DBNull.System.IConvertible.ToInt32(IFormatProvider provider)
   at Duplicati.Library.SQLiteHelper.DatabaseUpgrader.UpgradeDatabase(IDbConnection connection, String sourcefile, String schema, IList`1 versions)
   --- End of inner exception stack trace ---
   at Duplicati.Library.SQLiteHelper.DatabaseUpgrader.UpgradeDatabase(IDbConnection connection, String sourcefile, String schema, IList`1 versions)
   at Duplicati.Library.SQLiteHelper.DatabaseUpgrader.UpgradeDatabase(IDbConnection connection, String sourcefile, Type eltype)
   at Duplicati.Library.Main.Database.LocalDatabase.CreateConnection(String path)
   at Duplicati.Library.Main.Database.LocalBackupDatabase..ctor(String path, Options options)
   at Duplicati.Library.Main.Operation.BackupHandler.Run(String[] sources, IFilter filter)
   at Duplicati.Library.Main.Controller.<>c__DisplayClass16_0.<Backup>b__0(BackupResults result)
   at Duplicati.Library.Main.Controller.RunAction[T](T result, String[]& paths, IFilter& filter, Action`1 method)
   at Duplicati.Library.Main.Controller.Backup(String[] inputsources, IFilter filter)
   at Duplicati.Server.Runner.Run(IRunnerData data, Boolean fromQueue)

Thanks for the details!

This is not the same error so we’ll have to start from scratch on this one. It looks like you were doing a backup when the error happened but I’m seeing UpgradeDatabase in the error message - is this a fresh install or an existing one that you recently updated to 2.0.2.1?

it was a fresh install. I can delete the database and start over if necessary.

Is the first run for the backup as well?

We can try to get your backup working or try to figure out what exactly is going on - do you have a preference?

If you just want to get thing working then I’d suggest you try some of the following:

  • In the backup job menu go to “Advanced -> Database” and click the “Recreate (delete and repair)” button and see if it runs
  • Use the backup job menu “Export… -> To File” to save your current backup job to a file, delete the job, then use “Add backup” to import the saved job and see if it runs
  • Un-install then re-install Duplicati (you can use “Add backup” to import your saved job from before) and see if it runs
  • Use the backup job menu “Export… -> As Command-line” then copy/paste your job settings into a post here (after removing sensitive data like user names, passwords, hashes etc.)

Note that you caught me at a good time for fast responses, unfortunately my time has run out so don’t feel ignored if it takes a while to get more replies. :slight_smile:

The relevant code is here:

From what I can guess, the call is SELECT COUNT(*) FROM SQLITE_MASTER WHERE Name LIKE 'Version'. If this fails, it is likely something to do with an incompatible version of SQLite being loaded.
Why or how it would load another version on Windows, I do not know.

The OP said it was fresh install, is UpgradeDatabase called on regular runs or do you think an unexpected sqlite version mismatch could get into this code?

The crash happens when Duplicati tries to figure out what database version there is. I have not seen it return null in this case before.

Good point, I missed that part.

@Omnicef I think maybe the empty database looks weird for some reason. If this is a new backup (as you mention) there is no sensitive data in it. Can you send me a copy of the database file? You can find the path by clicking the “Manage database …” menu under the backup name.