PowerShell script exchange
Post Reply
ShawnKPERS
Enthusiast
Posts: 61
Liked: 4 times
Joined: Apr 29, 2011 3:55 pm
Full Name: Shawn Nix
Contact:

Delete old backup set after a new chain is created.

Post by ShawnKPERS »

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.
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

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

Post by Vitaliy S. »

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!
ShawnKPERS
Enthusiast
Posts: 61
Liked: 4 times
Joined: Apr 29, 2011 3:55 pm
Full Name: Shawn Nix
Contact:

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

Post by ShawnKPERS »

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.
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

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

Post by Vitaliy S. »

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.
ShawnKPERS
Enthusiast
Posts: 61
Liked: 4 times
Joined: Apr 29, 2011 3:55 pm
Full Name: Shawn Nix
Contact:

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

Post by ShawnKPERS »

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.
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

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

Post by Vitaliy S. »

I'm not a Powershell expert either, but I'm sure Tom, Seth or Andreas (our PS gurus) will be able to help you.
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

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

Post by ThomasMc » 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
ShawnKPERS
Enthusiast
Posts: 61
Liked: 4 times
Joined: Apr 29, 2011 3:55 pm
Full Name: Shawn Nix
Contact:

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

Post by ShawnKPERS »

ThomasMc you are the man, that is exactly what I was looking for Thanks!!!
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

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

Post by ThomasMc »

Thanks Shawn, always happy to help :)
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests