script to copy recent .vbk to tape

PowerShell script exchange

script to copy recent .vbk to tape

Veeam Logoby markhumphreys » Wed Apr 09, 2014 2:53 pm

We have multiple backups that we require backing up to tape. We only want the last .vbk to be backed up. We currently have a 14 day retention to disk. We have tried reverse incremental but backup performance is too slow.
We have also tried to create hard-links via a PowerShell script but this filled the backup repository disk.

Does anyone have a script to do this....
markhumphreys
Novice
 
Posts: 6
Liked: never
Joined: Fri Apr 26, 2013 3:19 pm
Full Name: Mark Humphreys

Re: script to copy recent .vbk to tape

Veeam Logoby v.Eremin » Wed Apr 09, 2014 3:10 pm

Hi, Mark, what do you mean by "filled backup repository"? It shouldn't be that hard to just add some lines responsible for clearing previous hard-links. For instance, this script uses the described approach.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: script to copy recent .vbk to tape

Veeam Logoby markhumphreys » Wed Apr 09, 2014 3:24 pm

Hi,

By 'filled backup repository' I mean by using the hard-link option the backend storage gets consumed with the files created by the hard-link script
markhumphreys
Novice
 
Posts: 6
Liked: never
Joined: Fri Apr 26, 2013 3:19 pm
Full Name: Mark Humphreys

Re: script to copy recent .vbk to tape

Veeam Logoby v.Eremin » Wed Apr 09, 2014 4:10 pm

Not sure whether I completely follow you on that, but anyway. If the hard link scenario doesn't work for you, what about using some "staggering" area - the folder (called "Latest .vbk", for instance) that is specified as a source for file to tape job. Using PS commands, you will find and copy the latest full backup to it, and, then, execute the corresponding tape job. Once the tape job is finished, the backup files will be removed from the "staggering" area.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: script to copy recent .vbk to tape

Veeam Logoby beovax » Wed Apr 09, 2014 4:17 pm

Can a script be created which basically takes the backup jobs and finds the latest vbk for each backup job and adds this to an array? Then when the backup to tape runs the backup to tape job runs using the file location pointers in the array rather than using hard links or a separate staging area. Previously I have used a script to find the latest backup and write it to tape but this was the latest backup from one job rather than multiple jobs. Someone with the PowerShell script experience could surely be able to do a script which can do this with just using a pointer to the files and back them up without hard links or staging first?
beovax
Influencer
 
Posts: 15
Liked: never
Joined: Wed Dec 14, 2011 11:38 am

Re: script to copy recent .vbk to tape

Veeam Logoby v.Eremin » Thu Apr 10, 2014 8:45 am

Can a script be created which basically takes the backup jobs and finds the latest vbk for each backup job and adds this to an array?

Yes, it's possible.

Then when the backup to tape runs the backup to tape job runs using the file location pointers in the array rather than using hard links or a separate staging area.

Backup to tape job operates with backup jobs/repositories, rather than with particular files. Thus, it's impossible to point it to the specific .vbks/.vibs.

In order to copy given files you should use file to tape job, instead. However, currently it's not possible to change "source" settings of file to tape job, so, you have to use either "hardlinks" or "staggering" area.

You can provide previously used script here. I believe it wouldn't be that hard to modify it for your current needs.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: script to copy recent .vbk to tape

Veeam Logoby beovax » Thu Apr 10, 2014 8:59 am

Here is the script. Someone provided me this previously that works on the job name and takes the last successful job and writes the last backup to tape. What I would like to be able to do is for multiple job names scan the repository and copy the last successful vbk full backup to tape for each job that has been run. If their is anyone that has a piece of code that can do this task would appreciate it.

Code: Select all
   if ( (Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue) -eq $null )
   {
          Add-PsSnapin VeeamPSSnapIn

   }

    $VeeamJobName = "jobname"
    $backupExecJob   = "jobname"


    if ((Get-VBRJob | where {$_.Name -eq $VeeamJobName}).GetLastResult() -eq "Success")
    {
       $latestOib = Get-VBRBackup | where {$_.JobName -eq $VeeamJobName} | Get-VBRRestorePoint | sort CreationTime -Descending | select -First 1
       $latestOib
       $storage = $latestOib.GetStorage()
       $storage.FilePath

       $file = get-item $storage.FilePath


       if ($file.Attributes -band ([System.IO.FileAttributes]::Archive))
       {     
         & "d:\Program Files\Symantec\Backup Exec\bemcmd.exe" -o2 -j:$backupExecJob -s:$storage.FilePath -mTapes-Weekdays -r -w

    $file.Attributes = 'Archive'
       }
    }
beovax
Influencer
 
Posts: 15
Liked: never
Joined: Wed Dec 14, 2011 11:38 am

Re: script to copy recent .vbk to tape

Veeam Logoby v.Eremin » Thu Apr 10, 2014 9:08 am

Just to clarify situation before we proceed to script modification - you're going to use Backup Exec, not VB&R, to copy latest backup data to tape, right? I'm wondering because the script would differ in two cases. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: script to copy recent .vbk to tape

Veeam Logoby markhumphreys » Thu Apr 10, 2014 9:47 am

No that was an old script, we need to use VB&R thanks
markhumphreys
Novice
 
Posts: 6
Liked: never
Joined: Fri Apr 26, 2013 3:19 pm
Full Name: Mark Humphreys

Re: script to copy recent .vbk to tape

Veeam Logoby v.Eremin » Thu Apr 10, 2014 10:41 am

As mentioned above, the only possible way to archive specific file (latest .vbk) with current tape implementation is to use combination of file to tape job and hardlinks/staggering area. Both examples are provided in the referenced thread. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: script to copy recent .vbk to tape

Veeam Logoby markhumphreys » Fri Apr 11, 2014 1:40 pm

We have found this script for backing up with Backup Exec to tape. Surely this can be done within Veeam for backups to tape direct?

http://www.symantec.com/connect/forums/ ... ry-bue2012


Mark
markhumphreys
Novice
 
Posts: 6
Liked: never
Joined: Fri Apr 26, 2013 3:19 pm
Full Name: Mark Humphreys

Re: script to copy recent .vbk to tape

Veeam Logoby v.Eremin » Fri Apr 11, 2014 2:12 pm

As it's been said above, the backup to tape job has to do with backup jobs/repositories, rather than with individual backup files. So, it's not the option here, and you have to use file to tape job, if you're after archiving certain files.

The problem with file to tape job is that Symantec PS snapin allows passing certain file/folders to tape jobs. Meanwhile, with our current PS implementation, once the "source" object is specified for file to tape job, it cannot be changed no matter what. So, you have to resort to hardlinks/staggering area approaches.

Hope this makes sense.
Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: script to copy recent .vbk to tape

Veeam Logoby beovax » Fri Apr 11, 2014 3:08 pm

Looking into the Add-VBRTapeFilesJob it accepts multiple files. So I would have assumed the hardlink script that collects the filenames could write these to an array which could be passed to the add-VBRTapeFiles command or is that a limitation of the available command set?

Code: Select all
# create hardlinks from latest vbk files, erase online tape media and start backup job
# joerg riether
# august 2013
# NOT for ANY production use!
# only for experimetal purposes in testlabs
# please do NOT use this if you are not 100% sure what you are doing, this will erase your tape media!

add-pssnapin veeampssnapin

# Settings

$linkpath = "d:\veeam\veeam-hardlinks\"
$backuppath = "d:\veeam\veeam-backup\"

# kill previous hard links

del $linkpath*.*

# use with caution
# this will kill everything it finds in the drives

$tape = get-vbrtapemedium | Where-Object {$_.IsOnline -like "True"}
Erase-VBRTapeMedium -Medium $tape -Confirm:$false

# this will find the latest vbk files for you recursively starting from your backup path.

$files = dir $backuppath -filter "*.vbk" -rec
$filteredfiles = $files | group directory | foreach {@($_.group | sort {[datetime]$_.creationtime} -desc)[0]}

# this loop will separate path and name and it will create your hard links

ForEach ($File in $filteredfiles)
        {
        $FilePath = $File.DirectoryName
        $FileName = $File.Name
        cmd /c mklink /H $linkpath$Filename $Filepath\$Filename
        }

# call your backup to tape from file job pointing to your hard link path

Start-VBRJob -Job "FileToTapeL" -FullBackup

Add-VBRTapeFilesJob -Name "Files to tape backup job 1" -Server $server -Path "C:\backup\Backup Job 01\VM01 Backup Job 01.vbm" -MediaPool $mediapool
beovax
Influencer
 
Posts: 15
Liked: never
Joined: Wed Dec 14, 2011 11:38 am

Re: script to copy recent .vbk to tape

Veeam Logoby v.Eremin » Fri Apr 11, 2014 3:19 pm

I'm not sure whether I follow you on that.

The script provided by you was referenced in the second post. It finds latest .vbk file, creates a hard link for it, and, then, executes the corresponding file to tape job. This script will work, if the file to tape job has been already created and pointed to the "hardlink" directory. The last line you've added creates a new file to tape job named "Files to tape backup job 1" that has backup metadata as it source ("C:\backup\Backup Job 01\VM01 Backup Job 01.vbm").

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: script to copy recent .vbk to tape

Veeam Logoby beovax » Fri Apr 11, 2014 3:32 pm

Apologies, ignore the last line. What I was asking was can the script rather than build up a separate folder location with hard links. Run through the loop writing the file location into a variable that could be passed to the backup job to run.

So for example I have 3 backup jobs (Backup1,Backup2, Backup3) these jobs have 14 days retention on disk. I then run a script that looks in each of these locations and just gets the latest full backup job. Then it writes that location to a variable I.e

C:\backuplocation\full1.vbk

It runs through the loop a second time and writes

C:\backuplocation2\full2.vbk to an array or another variable

Then once all locations are scanned I can pass this to the VBR-Tape command $full1,$full2 to write these to the tape.

Is this possible? I have seen people do similar things to this when using Symantec Backup Exec passing the files as a selection list. So was hoping this would be an option via the Veeam powershell command set.
beovax
Influencer
 
Posts: 15
Liked: never
Joined: Wed Dec 14, 2011 11:38 am

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests