Find backup files that no longer exist physically

PowerShell script exchange

Find backup files that no longer exist physically

Veeam Logoby cerede2000 » Wed Sep 10, 2014 7:37 am

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 ?
cerede2000
Influencer
 
Posts: 16
Liked: 1 time
Joined: Tue Sep 09, 2014 2:24 pm
Full Name: Benjamin CEREDE

Re: Find backup files that no longer exist physically

Veeam Logoby v.Eremin » Wed Sep 10, 2014 8:54 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Find backup files that no longer exist physically

Veeam Logoby cerede2000 » Wed Sep 10, 2014 8:56 am

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 :)
cerede2000
Influencer
 
Posts: 16
Liked: 1 time
Joined: Tue Sep 09, 2014 2:24 pm
Full Name: Benjamin CEREDE

Re: Find backup files that no longer exist physically

Veeam Logoby v.Eremin » Wed Sep 10, 2014 10:14 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Find backup files that no longer exist physically

Veeam Logoby cerede2000 » Wed Sep 10, 2014 11:49 am

Thanks.

But how I spend
Code: Select all
$Storages.FilePath

To
Code: Select all
$RPtodelete = $OrphanedStorages.GetOibs()

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

Re: Find backup files that no longer exist physically

Veeam Logoby v.Eremin » Wed Sep 10, 2014 12:03 pm

You will receive a list of file paths, analyze those (whether or not given files exist), and assign non-existing to $OrphanedStorages variable. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Find backup files that no longer exist physically

Veeam Logoby cerede2000 » Wed Sep 10, 2014 12:23 pm

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 ?
cerede2000
Influencer
 
Posts: 16
Liked: 1 time
Joined: Tue Sep 09, 2014 2:24 pm
Full Name: Benjamin CEREDE

Re: Find backup files that no longer exist physically

Veeam Logoby v.Eremin » Wed Sep 10, 2014 12:48 pm

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Find backup files that no longer exist physically

Veeam Logoby cerede2000 » Wed Sep 10, 2014 12:50 pm

Ok :(

So I'll wait for Veeam cleans itself.

It's sad that this function is not available.
cerede2000
Influencer
 
Posts: 16
Liked: 1 time
Joined: Tue Sep 09, 2014 2:24 pm
Full Name: Benjamin CEREDE

Re: Find backup files that no longer exist physically

Veeam Logoby v.Eremin » Fri Sep 12, 2014 11:11 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Find backup files that no longer exist physically

Veeam Logoby cerede2000 » Fri Sep 12, 2014 11:27 am

Okay, but how to remove only a chain and not all the points of a VM?
cerede2000
Influencer
 
Posts: 16
Liked: 1 time
Joined: Tue Sep 09, 2014 2:24 pm
Full Name: Benjamin CEREDE

Re: Find backup files that no longer exist physically

Veeam Logoby v.Eremin » Fri Sep 12, 2014 11:47 am

Can you elaborate on that? I'm a little bit confused as my understanding suggests that chain means "all restore points of VM". Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests