PowerShell script exchange
Post Reply
freakiegamer
Novice
Posts: 3
Liked: never
Joined: Jul 14, 2015 2:43 pm
Full Name: Cory Clouse
Contact:

Automating Tape Backups

Post by freakiegamer »

Ok - So I have a customer that wants to heavily automate and ignore best practices for their tape backup system and make it so they never have to look at their veeam server (Against my recommendations)

They have a single tape drive (hp ultrium LTO-6) and what they want to happen is this:

*VM backup jobs run at nighttime and backup to disk
* They put in a random tape into their drive sometime in the middle of the day
* Veeam then erases and writes full backup onto tape and then eject when done via tape job which copies backup repo
* Next day middle of day, they take out ejected tape and then put in another random tape into drive to repeat cycle

So the big problem here is the random tape part. There is a very large chance that this tape will have never been seen before on the Veeam server. So, this drive needs inventoried, the media needs set to a pool, the media needs erased, the media needs turned online.

So - I was hoping someone could help me write a powershell script that will run after the VM backup job and initiate this whole process. Below is what I have so far.

Code: Select all

    Add-PSSnapin VeeamPSSnapin
    Get-VBRTapeDrive | Start-VBRTapeInventory
    $tape = Get-VBRTapeMedium | Where-Object {$_.IsOnline -like "True"}
    $tape.MarkAsFree()
    #Move-VBRTapeMedium -Medium $tape -MediaPool "Media Pool 1" -Confirm:$false
    Start-VBRJob -Job "Backup to Tape Job 1" -FullBackup
    #Eject-VBRTapeDrive -Drive "Tape0"
    Pause
Dima P.
Product Manager
Posts: 14726
Liked: 1706 times
Joined: Feb 04, 2013 2:07 pm
Full Name: Dmitry Popov
Location: Prague
Contact:

Re: Automating Tape Backups

Post by Dima P. »

Hello and welcome to the community,

I was thinking you could add the script to run before tape job just via tape job settings (tape job – options – advanced – pre/post job activities)? If so the script should look like this:

Code: Select all

Get-VBRTapeLibrary | Start-VBRTapeInventory
$tape = Get-VBRTapeMedium | Where-Object {$_.IsOnline -like "True"}
$tape.MarkAsFree()
#Move-VBRTapeMedium -Medium $tape -MediaPool "Media Pool 1" -Confirm:$false
freakiegamer
Novice
Posts: 3
Liked: never
Joined: Jul 14, 2015 2:43 pm
Full Name: Cory Clouse
Contact:

Re: Automating Tape Backups

Post by freakiegamer »

Thank you,

Looks good. I think a pre-run script sounds a lot better than my idea... I can't imagine why I wouldn't have thought of that... Will this erase the disk if it has data on it? I really don't know what the "markasfree" does to prepare the disk.

I cannot test to ensure function yet but I will attempt it soon.
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Automating Tape Backups

Post by veremin »

MarkAsFree method previously available for Medium entity is no longer present in version 8, so, now in order to mark tape as free, the script should be re-written a bit:

Code: Select all

$MediaPool = Get-VBRTapeMediaPool -Name "Free"
Move-VBRTapeMedium -Medium $Medium -MediaPool $MediaPool
Honestly, I think you're about to do something similar to what has been described previously; might be worth reviewing.

Thanks.
freakiegamer
Novice
Posts: 3
Liked: never
Joined: Jul 14, 2015 2:43 pm
Full Name: Cory Clouse
Contact:

Re: Automating Tape Backups

Post by freakiegamer »

I am using v8 so that certainly would cause issues.

That linked post seems very close to what I am wanting to achieve here. I will play around with the code there and see what I can mash together.
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Automating Tape Backups

Post by veremin »

Should any assistance be needed, kindly, let us know. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests