Automating Tape Backups

PowerShell script exchange

Automating Tape Backups

Veeam Logoby freakiegamer » Tue Jul 14, 2015 2:48 pm

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
freakiegamer
Novice
 
Posts: 3
Liked: never
Joined: Tue Jul 14, 2015 2:43 pm
Full Name: Cory Clouse

Re: Automating Tape Backups

Veeam Logoby Dima P. » Tue Jul 14, 2015 3:36 pm

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
Dima P.
Veeam Software
 
Posts: 6249
Liked: 440 times
Joined: Mon Feb 04, 2013 2:07 pm
Location: SPb
Full Name: Dmitry Popov

Re: Automating Tape Backups

Veeam Logoby freakiegamer » Tue Jul 14, 2015 4:15 pm

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.
freakiegamer
Novice
 
Posts: 3
Liked: never
Joined: Tue Jul 14, 2015 2:43 pm
Full Name: Cory Clouse

Re: Automating Tape Backups

Veeam Logoby v.Eremin » Tue Jul 14, 2015 4:47 pm

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.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Automating Tape Backups

Veeam Logoby freakiegamer » Tue Jul 14, 2015 5:11 pm

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.
freakiegamer
Novice
 
Posts: 3
Liked: never
Joined: Tue Jul 14, 2015 2:43 pm
Full Name: Cory Clouse

Re: Automating Tape Backups

Veeam Logoby v.Eremin » Tue Jul 14, 2015 5:21 pm

Should any assistance be needed, kindly, let us know. Thanks.
v.Eremin
Veeam Software
 
Posts: 13281
Liked: 970 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 7 guests