PowerShell script exchange
Post Reply
cerede2000
Influencer
Posts: 16
Liked: 1 time
Joined: Sep 09, 2014 2:24 pm
Full Name: Benjamin CEREDE
Contact:

Find backup files that no longer exist physically

Post by cerede2000 »

Hello,

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}
And if I want to remove the base Veeam it I just need to call the Delete method ?

Code: Select all

$filesNotExists | %{$_.Delete()}
Thanks :)


Edit : I tried the Delete method but :
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
How do I delete a file properly ?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Find backup files that no longer exist physically

Post by veremin »

What do you mean by physically don't exist? Are you talking about restore points that are present in backup console, but are not on actual repository - those that have been deleted manually, bypassing automatic retention? Thanks.
cerede2000
Influencer
Posts: 16
Liked: 1 time
Joined: Sep 09, 2014 2:24 pm
Full Name: Benjamin CEREDE
Contact:

Re: Find backup files that no longer exist physically

Post by cerede2000 »

Indeed !
A colleague points restoration remove manually (just deleting the files !)

So I would clean inlets restore points that no longer exists physically.

And after properly delete if need.

Thanks :)
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Find backup files that no longer exist physically

Post by veremin »

In this case, you will need to

1) Get a backup of given job first:

Code: Select all

$Backup = Get-VBRBackup -Name "Backup Job MiniMe"
2) Get corresponding storages:

Code: Select all

$Storages = $Backup.GetStorages()
3) Find out file paths:

Code: Select all

$Storages.FilePath
4) Check whether or not files exist, using Test-Path commandlet.

5) Get restore points existing only in GUI.

Code: Select all

$RPtodelete = $OrphanedStorages.GetOibs()
6) Delete them, using Remove-VBRRestorePoint. Though, I'm not sure how Remove-VBRRestorePoint will work in that situation. Thus, I recommend testing it first prior to implementing.

Thanks.
cerede2000
Influencer
Posts: 16
Liked: 1 time
Joined: Sep 09, 2014 2:24 pm
Full Name: Benjamin CEREDE
Contact:

Re: Find backup files that no longer exist physically

Post by cerede2000 »

Thanks.

But how I spend

Code: Select all

$Storages.FilePath
To

Code: Select all

$RPtodelete = $OrphanedStorages.GetOibs()
?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Find backup files that no longer exist physically

Post by veremin »

You will receive a list of file paths, analyze those (whether or not given files exist), and assign non-existing to $OrphanedStorages variable. Thanks.
cerede2000
Influencer
Posts: 16
Liked: 1 time
Joined: Sep 09, 2014 2:24 pm
Full Name: Benjamin CEREDE
Contact:

Re: Find backup files that no longer exist physically

Post by cerede2000 »

Ok :)

But Oibs return complete VM and delete all restorepoint attached at this VM !

It's not possible to delete only one restorepoint for one VM ?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Find backup files that no longer exist physically

Post by veremin »

As mentioned in the referenced thread, it's not possible to delete one restore point in both GUI and PS. I'm not sure whether it's applicable to non-existing restore points, though. Thanks.
cerede2000
Influencer
Posts: 16
Liked: 1 time
Joined: Sep 09, 2014 2:24 pm
Full Name: Benjamin CEREDE
Contact:

Re: Find backup files that no longer exist physically

Post by cerede2000 »

Ok :(

So I'll wait for Veeam cleans itself.

It's sad that this function is not available.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Find backup files that no longer exist physically

Post by veremin »

The best idea, indeed. The individual restore point deletion isn't present either in GUI nor in PS, so that, someone can't break a backup chain. Thanks.
cerede2000
Influencer
Posts: 16
Liked: 1 time
Joined: Sep 09, 2014 2:24 pm
Full Name: Benjamin CEREDE
Contact:

Re: Find backup files that no longer exist physically

Post by cerede2000 »

Okay, but how to remove only a chain and not all the points of a VM?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Find backup files that no longer exist physically

Post by veremin »

Can you elaborate on that? I'm a little bit confused as my understanding suggests that chain means "all restore points of VM". Thanks.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 17 guests