The process cannot access the file because it is being used by another process

KB ID: 1960
Product: Veeam Backup & Replication
Published: 2014-11-19
Last Modified: 2023-01-03
Get weekly article updates
By subscribing, you are agreeing to have your personal information managed in accordance with the terms of Veeam's Privacy Notice.

Cheers for trusting us with the spot in your mailbox!

Now you’re less likely to miss what’s been brewing in our knowledge base with this weekly digest

error icon

Oops! Something went wrong.

Please try again later.

Challenge

A job fails, indicating that a file is locked by another process/task. The console may indicate specifically what file is locked. Identification of the process that is locking the file(s) must take place.

Solution

NAS Involvement
While a process on a NAS can lock a file, due to the way some NAS devices may restrict terminal access, it can be challenging to identify if any processes on the NAS itself are locking files. If a reboot of the NAS does not resolve the lock, it may be necessary to involve the storage vendor.

Windows:

There are a few utilities that can show File Locks. Pre-installed is Resource Monitor.
 
User-added image
 
In this example, there is a PID for the VeeamAgent process, meaning Veeam has a lock on this file. The agent responsible for this lock can be confirmed in logging, or with the assistance of support. The PID of a given agent exists at the beginning of any source or target agent log. In the case of file locks, the target agent log should be examined.
 
< 23740>   Windows agent.
< 23740>   Path to the executable module: C:\Program Files (x86)\Veeam\Backup Transport\x64\VeeamAgent.exe
< 23740>   Agent version: 9.5.0.1536
< 23740>   Installed memory, MB: 8191
< 23740>   PID: 18232

Linux:

There are utilities that can be used to determine File Locks on a Linux repository, and this section will cover the usage of lslocks. However, there may be other distribution-specific utilities and methods. It is critical to differentiate between Locked and Opened files. It is possible for a file to be in a locked state but not be actively opened. A command like lsof will only list actively opened files.

  • LSLOCKS — Requires util-linux package
  • LSOF — LSOF used without any options will show a list of all open files belonging to active processes. Specifying a particular file will show active processes for that file. If the file name is known using the following:
    lsof “\path\to\file”
    

 

Manually investigating /proc/locks can also be done like so:

sudo find -L /proc/*/fd -maxdepth 1 -print -exec readlink {} \;

In either scenario, one must verify that the file is not actively modified. File Locks can come from a variety of sources. If a job is unexpectedly terminated due to a network drop, it is plausible that the Veeam Agent finished but never received a terminate command. If the repository uses deduplication, the storage may have too aggressive of a profile active and is locking the file(s) as soon as Veeam releases a lock on them.

Once verified that the locked file is no longer being modified, it is safe to manually kill any process still maintaining a lock on the file.

Killing a process that is modifying a file may result in a corrupted file.

To submit feedback regarding this article, please click this link: Send Article Feedback
To report a typo on this page, highlight the typo with your mouse and press CTRL + Enter.

Spelling error in text

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Thank you!

Thank you!

Your feedback has been received and will be reviewed.

Oops! Something went wrong.

Please try again later.

KB Feedback/Suggestion

This form is only for KB Feedback/Suggestions, if you need help with the software open a support case

By submitting, you are agreeing to have your personal information managed in accordance with the terms of Veeam's Privacy Notice.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Verify your email to continue your product download
We've sent a verification code to:
  • Incorrect verification code. Please try again.
An email with a verification code was just sent to
Didn't receive the code? Click to resend in sec
Didn't receive the code? Click to resend
Thank you!

Thank you!

Your feedback has been received and will be reviewed.

error icon

Oops! Something went wrong.

Please try again later.