Clear old backup chain from CIFS repository

PowerShell script exchange

Clear old backup chain from CIFS repository

Veeam Logoby resruss » Tue Jun 14, 2016 6:00 am

Hi All,

I've started using my first Backup Copy Job that's backed by rotatable media.
The repository is 2 NAS rotated periodically, they both have the same IP and UNC share.

The Backup Copy is working fantastic, from what I understand there's a ForceDeleteBackupFiles registry key, which we've set to 3, but it nuked all files in the folder.
We're running Veeam v9 and have checked the Backed by rotatable media setting on the repository.

I understand that retention doesn't work as it should on a CIFS share as a new backup chain is created when the media is rotated.

So what we noticed, the Backup Copy Job was set to:
- Forever Forward Incremental (no synthetic fulls created)
- Restore points was set to 4
At any point there was 2 - 4 VBK files and 3 VIBs between each chain, which I would expect
We're looking for a way to remove the old chains once the new one is created, retaining just a single copy of the VBK and VIBs for the current chain

Is there any way to achieve this on CIFS, using PowerShell as a pre/post job?

Ideally, what we'd be after is if the backup chain no longer exists in the Veeam catalog, remove it from disk, but I'm not sure if this is possible in PowerShell, or too dangerous to do.

Has anyone implemented something like this, or going to?
resruss
Service Provider
 
Posts: 55
Liked: 6 times
Joined: Mon Apr 30, 2012 2:04 am

Re: Clear old backup chain from CIFS repository

Veeam Logoby PTide » Tue Jun 14, 2016 1:54 pm

Hi,

How about using a powershell script that deletes all files that are older than the newest .vbk? Just keep in mind that in case backup copy job continues current chain the script will also delete vibs, so you should either add extra logic in the scripts or set it to run on the selected days only (days when you rotate media).

Thanks
PTide
Veeam Software
 
Posts: 3022
Liked: 247 times
Joined: Tue May 19, 2015 1:46 pm

Re: Clear old backup chain from CIFS repository

Veeam Logoby resruss » Wed Jun 15, 2016 2:02 am

That's not a bad idea, based on that information, I've had an idea, which may be safer.

Is it possible to query Veeam via PowerShell to return the path and filenames for all VBK and VIBs in a backup copy chain, then we can just delete everything that doesn't match that?

I have no idea where to start with that though, or if it's even possible
resruss
Service Provider
 
Posts: 55
Liked: 6 times
Joined: Mon Apr 30, 2012 2:04 am

Re: Clear old backup chain from CIFS repository

Veeam Logoby v.Eremin » Tue Jun 21, 2016 10:25 am

The variable $Data in the below example should contain backup copy jobs names along with paths of actual backup files:
Code: Select all
asnp VeeamPSSnapin
$Data = @()
Foreach ($Backup in (Get-VBRBackup | where {$_.JobType -eq "BackupSync"}))
{
$BackupObject = New-Object psobject
$BackupObject | Add-Member -MemberType NoteProperty -Name "JobName" -Value $Backup.Name
$BackupObject | Add-Member -MemberType NoteProperty -Name "File path" -Value $Backup.getallstorages().filepath
$Data += $BackupObject
}


Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 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