PowerShell script exchange
Post Reply
resruss
Service Provider
Posts: 56
Liked: 6 times
Joined: Apr 30, 2012 2:04 am
Contact:

Clear old backup chain from CIFS repository

Post by resruss »

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?
PTide
Product Manager
Posts: 6551
Liked: 765 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Clear old backup chain from CIFS repository

Post by PTide »

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
resruss
Service Provider
Posts: 56
Liked: 6 times
Joined: Apr 30, 2012 2:04 am
Contact:

Re: Clear old backup chain from CIFS repository

Post by resruss »

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
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Clear old backup chain from CIFS repository

Post by veremin »

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.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests