On another note I would like to identify files that have been deleted physically (without using Veeam).
Is this is good?
Code: Select all
$bkp = Get-VBRBackup -Name '<JobName>'
$filesNotExists = $bkp.GetStorages() | Sort-Object -Descending CreationTime | ?{(Test-Path $_.FilePath) -eq $False}
Code: Select all
$filesNotExists | %{$_.Delete()}

Edit : I tried the Delete method but :
How do I delete a file properly ?Exception calling "Delete" with "0" argument(s): "Microsoft SQL server hosting the configuration database is currently
unavailable. Possible reasons are heavy load, networking issue, server reboot, or hot backup.
Please wait, and try again later.
Error information:
The DELETE statement conflicted with the REFERENCE constraint "FK_OIBs_Storages". The conflict occurred in database "Ve
eamBackup", table "dbo.Backup.Model.OIBs", column 'storage_id'.
The statement has been terminated."
At line:1 char:112
+ $bkp.GetStorages() | Sort-Object -Descending CreationTime | ?{(Test-Path $_.FilePath) -eq $False} | %{$_.Delete <<<<
()}
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException