# The database file is locked after stopping backup job

**URL:** https://forum.duplicati.com/t/the-database-file-is-locked-after-stopping-backup-job/3761
**Category:** Support
**Created:** [June 7, 2018, 7:01pm UTC](https://forum.duplicati.com/t/the-database-file-is-locked-after-stopping-backup-job/3761 "2018-06-07T19:01:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![herbert](https://forum.duplicati.com/user_avatar/forum.duplicati.com/herbert/32/1865_2.png) [@herbert](https://forum.duplicati.com/u/herbert)
#### Post date: [June 7, 2018, 7:01pm UTC](https://forum.duplicati.com/t/the-database-file-is-locked-after-stopping-backup-job/3761/1 "2018-06-07T19:01:28Z")

</div>

I reference another topic here as well, because this one resulted in the above issue 😃

> [@Stop after Upload](https://forum.duplicati.com/t/stop-after-upload/3753/7):
>
> I need to add something to this Today I tested another backup on the same machine using the same duplicati instance. The initial backup was already done previously, this was just an increment run and backing up data via SFTP to a remote location. Doing a Stop after upload on this job was working as expected.

After _stop after upload_ didn’t work but I needed to stop the backup, I used _stop_ and moved the data which was locally to a remote location where all the other data is located as well.  
The other backup jobs work great, but this one makes headaches.

600GB of 1,4TB were transfered and now if I start the job I get

**The database file is locked database is locked**

I need to fix this without losing the backup data, it took me already quite long to create the 600GB archives.

---

<div class="post-metadata">

### Author: ![kenkendk](https://forum.duplicati.com/user_avatar/forum.duplicati.com/kenkendk/32/5305_2.png) [@kenkendk](https://forum.duplicati.com/u/kenkendk)
#### Post date: [June 8, 2018, 7:39am UTC](https://forum.duplicati.com/t/the-database-file-is-locked-after-stopping-backup-job/3761/2 "2018-06-08T07:39:57Z")

</div>

In the other post you mention QNAP, so I assume this is still the case.

To check why the database is locked, you need to first get the database path.  
You can get it a number of ways, one is to use “Export” then “As commandline” on the backup job, and look for `--dbpath=`.

Then you need to use `lsof <dbpath>` from a commandline or similar. This will tell you which processes are locking the file. To recover, you should be able to restart the programs locking the database, and then Duplicati should get access again.

Quick and dirty fix, is to reboot the system, hereby restarting all processes.

---

<div class="post-metadata">

### Author: ![herbert](https://forum.duplicati.com/user_avatar/forum.duplicati.com/herbert/32/1865_2.png) [@herbert](https://forum.duplicati.com/u/herbert)
#### Post date: [June 8, 2018, 8:26am UTC](https://forum.duplicati.com/t/the-database-file-is-locked-after-stopping-backup-job/3761/3 "2018-06-08T08:26:20Z")

</div>

> [@kenkendk](#):
>
> To check why the database is locked, you need to first get the database path.  
> You can get it a number of ways, one is to use “Export” then “As commandline” on the backup job, and look for `--dbpath=` .
> 
> Then you need to use `lsof <dbpath>` from a commandline or similar. This will tell you which processes are locking the file. To recover, you should be able to restart the programs locking the database, and then Duplicati should get access again.

Great, I got a step further 🙂  
I can now rerun the backup job, but instead of the database locked error I get

> Error while running _name_  
> One or more errors occured.

The log data shows a **list** with lots of entries (5136 to be precise)  
Which all look similar to

> {“Name”:“duplicati-ifd2fcc476abe489a8b44868f93373175.dindex.zip.aes”,“LastAccess”:“2018-06-01T19:00:25+02:00”,“LastModification”:“2018-06-01T19:00:25+02:00”,“Size”:34877,“IsFolder”:false}

I just don’t understand where the _error_ is.

---

<div class="post-metadata">

### Author: ![mikedunn](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/m/67e7ee/32.png) [@mikedunn](https://forum.duplicati.com/u/mikedunn)
#### Post date: [March 11, 2019, 11:15pm UTC](https://forum.duplicati.com/t/the-database-file-is-locked-after-stopping-backup-job/3761/4 "2019-03-11T23:15:07Z")

</div>

Sorry to revive an old thread, but I had this same issue yesterday (on 2.0.4.5 beta) after I noticed a backup stuck for hours on the verifying step. No amount of rebooting, restarting the Duplicati Windows service, removing/adding the B2 configuration, or logging out/in to Windows removed the lock. Something (I think restarting the service) caused the error to change from “the database file is locked database is locked” to “the process cannot access the file ‘\<path to .sqlite db file\>’ because it is being used by another process”. I even moved the old database and let Duplicati create a new one, but that still didn’t resolve it. I did also verify the “lock\_v2” file was being removed whenever I did a stop/start, but that had no affect either.

Ultimately what I did was stop the service, delete the “control\_dir\_v2” directory and the Duplicati-server.sqlite file, reimport my B2 configuration, start the service, and re-point to the original db. That seemed to fix it.

Thanks,  
Mike
