Comprehensive data protection for all workloads
Post Reply
GlacierWaterIT
Novice
Posts: 3
Liked: never
Joined: Aug 15, 2012 6:34 pm
Full Name: Wesley Olins
Contact:

Feature Request - Delete old Backups

Post by GlacierWaterIT »

I hope I am not the only one that would appreciate this request.
Currently we have a Powershell script that runs as a scheduled task to delete backup files after X days (X being the retention period date).
If Veeam had the ability to delete files after their retention period lapsed that would be great so we didn't have to rely on a scheduled task with a service account (which the password can change) causing the scheduled task to fail without notifying us.

So anyone else can use the script I will paste it below until Veeam (Hopefully) integrates this in a later release/patch :)

Code: Select all

#Gets the current date of the system.

$Now = Get-Date

#Days to keep on hand
$Days = "9"

#Select location of files, network location work.  Ex: \\Server\Share

$TargetFolder = "LocationOfFiles"

#Specify the extension you would like to use (VRB,VBK,VIB)

$Extension = "*.vbk"

#This defines the amount of days to keep on hand for the deletion.

$LastWrite = $Now.AddDays(-$Days)

#Defines files based on the last write time filter and specified folder.

$Files = Get-Childitem $TargetFolder -Include $Extension -Recurse | Where {$_.LastWriteTime -le "$LastWrite"}

foreach ($File in $Files)
    {
    if ($File -ne $NULL)
        {
        write-host "Deleting File $File" -ForegroundColor "DarkRed"
        Remove-Item $File.FullName | out-null
        }
    else
        {
        Write-Host "No more files to delete!" -foregroundcolor "Green"
        }
    }
chrisdearden
Veteran
Posts: 1531
Liked: 226 times
Joined: Jul 21, 2010 9:47 am
Full Name: Chris Dearden
Contact:

Re: Feature Request - Delete old Backups

Post by chrisdearden »

What kind of backups are you trying to delete?

the retention policies do clear up old restore points.

going for a fixed number of days if you are using a forward incremental file is a really , REALLY bad idea.
veremin
Product Manager
Posts: 20284
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Feature Request - Delete old Backups

Post by veremin »

Hi, Wesley.

I’m also strongly advice that you not use anything apart from automatic retention period in order to delete existing restore points. Not only will it confuse Veeam installation that will keep believing that already deleted restore points are still present, but also it will break backup chain in case of forward incremental backup mode.

Are there any reasons not to use automatic retention policy?

Thanks.
Post Reply

Who is online

Users browsing this forum: Paul.Loewenkamp, vmJoe and 104 guests