Delete old backup set after a new chain is created.

PowerShell script exchange

Delete old backup set after a new chain is created.

Veeam Logoby ShawnKPERS » Thu Apr 19, 2012 11:06 pm

Hello,

Lets say I have a job setup to do one reverse incremental backup each day on M-F with an active full created every Saturday and I have a retention period 6 restore points. This should allow me to keep a full weeks worth of backups on hand at any point in time. Now the way I see it is when I do a active full I am creating a new chain or "backup set" so then after the first week I end up with a Friday full and a Saturday full and all the incrementals before Friday are tied to the Friday full and all incrementals after Saturday are tied to the Saturday Full. This leaves me with two full backups and a hand full of old incrementals tied to an old backup set sitting in the backup folder at any point in time. Since I am putting these backups to tape and I want to only put the current weeks backups to the current weeks tape I figured the best way to do it is to lop off the old Friday's and before backups so I only keep one backup set on hand at any point in time.

Is there a way to do this via GUI or Veeam Powershell commandlets in a post script that runs on a successful active full backup without having to create a standard powershell script that goes off using the file names or when they were created/modified? I can do this with standard commands but I wanted to do it in a cleaner way using just Veeams built in commands.
ShawnKPERS
Enthusiast
 
Posts: 49
Liked: 4 times
Joined: Fri Apr 29, 2011 3:55 pm
Full Name: Shawn Nix

Re: Delete old backup set after a new chain is created.

Veeam Logoby Vitaliy S. » Fri Apr 20, 2012 8:48 am

Hi Shawn,

There is no way to do that within the GUI, as a number of restore points is exclusively controlled by your retention policy settings.

If you decide to remove these points manually (Powershell or any other way), please keep in mind that these restore points records will not be removed from the database, in other words these points will be still visible in the restore wizard.

Thanks!
Vitaliy S.
Veeam Software
 
Posts: 19558
Liked: 1102 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: Delete old backup set after a new chain is created.

Veeam Logoby ShawnKPERS » Fri Apr 20, 2012 12:00 pm

Vitality,

Thanks for the reply, I was hoping for a clean way to remove them to avoid just what you stated were it will keep the records of the removed backups, but will it removed the records after the retention period is up for each restore point or will it keep it in the database since it will be unable to find the file to remove it? I also thought of trying to modify the retention period in powershell on the Saturdays back up so that it would automatically remove the previous backups after the Saturday full was finished and then run a post script on Monday that would reapply the 6 point retention setting back to the job. I have not had the chance to test this yet so I am not sure it will work.
ShawnKPERS
Enthusiast
 
Posts: 49
Liked: 4 times
Joined: Fri Apr 29, 2011 3:55 pm
Full Name: Shawn Nix

Re: Delete old backup set after a new chain is created.

Veeam Logoby Vitaliy S. » Fri Apr 20, 2012 2:01 pm

ShawnKPERS wrote:...but will it removed the records after the retention period is up for each restore point or will it keep it in the database since it will be unable to find the file to remove it?

Yes, retention policy will remove all restore points entries according to its configuration.
Vitaliy S.
Veeam Software
 
Posts: 19558
Liked: 1102 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: Delete old backup set after a new chain is created.

Veeam Logoby ShawnKPERS » Fri Apr 20, 2012 2:07 pm

I am new to Veeam powershell commands and I am having trouble finding where I can modify the retention number on an existing backup job. Any help would be appreciated.
ShawnKPERS
Enthusiast
 
Posts: 49
Liked: 4 times
Joined: Fri Apr 29, 2011 3:55 pm
Full Name: Shawn Nix

Re: Delete old backup set after a new chain is created.

Veeam Logoby Vitaliy S. » Fri Apr 20, 2012 2:32 pm

I'm not a Powershell expert either, but I'm sure Tom, Seth or Andreas (our PS gurus) will be able to help you.
Vitaliy S.
Veeam Software
 
Posts: 19558
Liked: 1102 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: Delete old backup set after a new chain is created.

Veeam Logoby ThomasMc » Fri Apr 20, 2012 3:23 pm 3 people like this post

This should get us started :)

Code: Select all
#Get the job we want to change
$job = Get-VBRJob -Name "LAB - DC AA Backup"

#keep a copy of the options before we change anything
$oldOpts = $job | Get-VBRJobOptions
#this is the object we'll change
$newOpts = $job | Get-VBRJobOptions

#print out the options your looking to change
$newOpts.BackupStorageOptions

#CheckRetention        : True
#RetainCycles          : 14
#RetainDays            : 14
#CompressionLevel      : 6
#EnableDeduplication   : True
#StgBlockSize          : KbBlockSize1024
#EnableIntegrityChecks : True
#EnableFullBackup      : False
#BackupIsAttached      : False

#Change as needed e.g RetainDays = 22

#Save the changes
$job | Set-VBRJobOptions -Options $newOpts

#Start the job
$job | Start-VBRJob

#After job is complete, return the job to original config
$job | Set-VBRJobOptions -Options $oldOpts


You could reduce it down by piping a little more but thought this would be the best way to to show the process
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Delete old backup set after a new chain is created.

Veeam Logoby ShawnKPERS » Fri Apr 20, 2012 9:25 pm

ThomasMc you are the man, that is exactly what I was looking for Thanks!!!
ShawnKPERS
Enthusiast
 
Posts: 49
Liked: 4 times
Joined: Fri Apr 29, 2011 3:55 pm
Full Name: Shawn Nix

[MERGED] Re: Delete old backup set after a new chain is crea

Veeam Logoby ThomasMc » Sat Apr 21, 2012 10:39 am

Thanks Shawn, always happy to help :)
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 4 guests