Velocity archives are created by default on a monthly basis to keep the size of the Velocity database manageable. When running a report containing archived dates, Velocity Services Account will temporarily attach the necessary archive files to the SQL Instance containing the specified dates. If the Velocity Services account does not have full control of the VelocityArchivexxx.MDF and VelocityArchivexxx.LDF files you will get a file permissions Error 5 when trying to run a report.
Manually Detach Velocity Archive from SQL instance.
Velocity archives can remain attached to the SQL instance if an archive report is started but not completed. This will happen if a user runs a report with too long a of a date range, becomes impatient, and terminates the report before it is completed.
File permissions are reset if a SQL user manually detaches the Velocity archive from the SQL Instance. You will need to manually grant Velocity Services account permissions to the VelocityArchivexxx.MDF and VelocityArchivexxx.LDF if the archives have been manually detached from the SQL Instance.
Moving Velocity Archive
By default, the Velocity archives VelocityArchivexxx.MDF and VelocityArchivexxx.LDF are owned and have full control by the Velocity Services account. Therefore, if you are trying to copy the Velocity Archives to another machine due to a Velocity database migration, you will be unable to do so due to lack of permissions. Bellow are instructions on granting permissions to copy these files.
Manually Set Velocity Archive Permissions
Velocity Archives are located in the same directory of the SQL Master Database. Commonly located at C:\Program Files\Microsoft SQL Server\MSSQL15.IDENTIV\MSSQL\DATA.
Right click on the VelocityArchivexxx.MDF > Properties > Security > Advanced
Change the owner to the local Administrators group.
Grant full control to the Velocity Services Account and the the local Administrators group.
Manually Set Velocity Archive Permissions via Command line
Velocity Archives are located in the same directory of the SQL Master Database. Commonly located at C:\Program Files\Microsoft SQL Server\MSSQL15.IDENTIV\MSSQL\DATA.
*Confirm the location of the Velocity archives and modify the commands with your directory path.
*Confirm the Velocity Services account name if you are using a custom Services account name and modify the commands with your custom Velocity Services account name.
Open an administrator Command Prompt
Run the following command to take ownership of the VelocityArchivexxx.MDF and VelocityArchivexxx.LDF files.
TAKEOWN /F "C:\Program Files\Microsoft SQL Server\MSSQL15.IDENTIV\MSSQL\DATA\VelocityArchive*.*" /A /R
Run the following command to grant full control of the VelocityArchivexxx.MDF and VelocityArchivexxx.LDF files to the Administrators Group.
icacls "C:\Program Files\Microsoft SQL Server\MSSQL15.IDENTIV\MSSQL\DATA\VelocityArchive*.*" /grant Administrators:F /T
Run the following command to grant full control of the VelocityArchivexxx.MDF and VelocityArchivexxx.LDF files to the Velocity Services Account.
icacls "C:\Program Files\Microsoft SQL Server\MSSQL15.IDENTIV\MSSQL\DATA\VelocityArchive*.*" /grant VelocityServices:F /T