backup naming when using reversed incremental

PowerShell script exchange

Re: backup naming when using reversed incremental

Veeam Logoby Vitaliy S. » Thu Jun 02, 2011 2:46 pm

Nile, glad that you've been able to figure it out. Nice job!

Yes, that's right. Seems like it has slipped out of my mind that currently we do not support triggering PowerShell scripts directly from the backup console.
Vitaliy S.
Veeam Software
 
Posts: 19575
Liked: 1104 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: backup naming when using reversed incremental

Veeam Logoby itldn » Fri Jun 03, 2011 8:11 am

I was so happy when the script ran successfully from within Veeam that i actually forgot to check the most crucial outcome of this script that is; The Latest Backup File will be backed up on a tape. This has disappointedly failed which indicates there is a fundamental issue with the script. i'll explain below

The steps of the script is as follow

1. Extract the latest Veeam backup file (VIB,VRB or VBK)
2. Pass this file to backup exec and run a predefined job on BE so that it can ONLY backup the passed veeam file from step 1
3. Set the Archive attribute again on the file

step 2 and step 3 don't work; to understand why; you need to analyse the script line where bemcmd.exe is used and also you will need the knowledge of how bemcmd works.
The line in step 2 is:
& "d:\Program Files\Symantec\Backup Exec\bemcmd.exe" -o1 -jJobName $storage.FilePath

bemcmd takes the following switches
-o1 this tells backup exec to start a job
-j this tells backup exec the job name
$storage.FilePath This supposed to tell backup exec the file path so that it can be backed up.

But bemcmd does not allow any think to be passed after you specify the job name therefore the file name is not passed as a result the tape is empty.

step 3 does not work
$file.Attributes = ($file.Attributes -bxor [System.IO.FileAttributes]::Archive)

I am not sure if i am doing something wrong but i hope that someone can shed some light to this problematic script

Thanks
itldn
Influencer
 
Posts: 24
Liked: never
Joined: Tue Mar 29, 2011 9:54 am

Re: backup naming when using reversed incremental

Veeam Logoby gshaw » Fri Jun 03, 2011 12:28 pm

Hmm this looks like a frustrating issue as I wanted to offload the reverse incremental .vbk to tape each week... is there no way to change the behaviour of the file naming or is there a working solution to the script?

Only other way I'll be able to get around it is to run an extra full backup but that's not ideal as it'll take some time to complete as opposed to using what's already there...
gshaw
Enthusiast
 
Posts: 51
Liked: never
Joined: Thu Apr 07, 2011 2:25 pm
Full Name: Gerrard Shaw

Re: backup naming when using reversed incremental

Veeam Logoby Vitaliy S. » Fri Jun 03, 2011 12:51 pm

Hello Gerrard,

Actually you can apply the following registry key to go back to our previous naming convention. But please be aware that that the workaround provided will change a VBK name after a Full run only.

Hope this helps.
Vitaliy S.
Veeam Software
 
Posts: 19575
Liked: 1104 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: backup naming when using reversed incremental

Veeam Logoby itldn » Fri Jun 03, 2011 1:42 pm

Hi Vitaliy,

I have managed to fix step 2- the new line should look like this
& "d:\Program Files\Symantec\Backup Exec\bemcmd.exe" -o2 -jJobName -s:$storage.FilePath -mMediaName -r

But please i need help with step 3 - this line is setting the attribute to Normal and not Archive (it is probably to do with the switch -bxor)
$file.Attributes = ($file.Attributes -bxor [System.IO.FileAttributes]::Archive)

But if i change the line to $file.Attributes = ($file.Attributes -bxor [System.IO.FileAttributes]::Normal)
then everything is fine but just the line now does not read logically. So please if you provide me with the right witches for the $file.Attributes -bxor this will probably fix it.


Please provide me with some documentation on Veeam cmd.

thanks,
itldn
Influencer
 
Posts: 24
Liked: never
Joined: Tue Mar 29, 2011 9:54 am

Re: backup naming when using reversed incremental

Veeam Logoby Vitaliy S. » Fri Jun 03, 2011 2:45 pm

Ok, let me consult with our PowerShell developer, he should be able to shed some light on this.
Vitaliy S.
Veeam Software
 
Posts: 19575
Liked: 1104 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: backup naming when using reversed incremental

Veeam Logoby Vitaliy S. » Mon Jun 06, 2011 9:54 am

Nile, here you go, this should help you in setting up proper attributes for the backup files:
http://stackoverflow.com/questions/464777/how-do-i-change-a-files-attribute-using-powershell
Vitaliy S.
Veeam Software
 
Posts: 19575
Liked: 1104 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: backup naming when using reversed incremental

Veeam Logoby itldn » Wed Jun 08, 2011 9:32 am

Hi Vitaliy,

thanks for the link, everything is working now.
itldn
Influencer
 
Posts: 24
Liked: never
Joined: Tue Mar 29, 2011 9:54 am

Re: backup naming when using reversed incremental

Veeam Logoby gshaw » Wed Jun 08, 2011 10:28 am

Does this mean the script is working OK now? Is the updated code available?
gshaw
Enthusiast
 
Posts: 51
Liked: never
Joined: Thu Apr 07, 2011 2:25 pm
Full Name: Gerrard Shaw

Re: backup naming when using reversed incremental

Veeam Logoby itldn » Thu Jun 09, 2011 9:12 am

Hi gshaw,
yes the script is working now.

Here it is for all of you. You need to call this powershell script from within a bat file
Remember to create a BE job before you run this script

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'
       }
    }


Thanks,

Nile
itldn
Influencer
 
Posts: 24
Liked: never
Joined: Tue Mar 29, 2011 9:54 am

Re: backup naming when using reversed incremental

Veeam Logoby gshaw » Sat Jun 11, 2011 7:24 pm

Thanks for this, good work 8)

I remember somewhere there was some info about how to pre-create the BE job but can't remember the thread, can someone copy back here for reference? Would be good to have the info all in one place :)
gshaw
Enthusiast
 
Posts: 51
Liked: never
Joined: Thu Apr 07, 2011 2:25 pm
Full Name: Gerrard Shaw

Re: backup naming when using reversed incremental

Veeam Logoby Vitaliy S. » Mon Jun 13, 2011 8:39 am

Here you go -> Writing to Tape Help
Vitaliy S.
Veeam Software
 
Posts: 19575
Liked: 1104 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Upgradeing Veeam 4 to 5 broke my backup strategy

Veeam Logoby MCoppola » Wed Jul 27, 2011 8:05 pm

[merged]

My backup strategy used Veeam 4 with reverse incremental backups. This worked out nice for me because I would retain the current file and past 4 increments (M-F) in a shared folder.

Every weeknight I would just copy the latest file after Veeam ran to get my current data backed up, and every weekend I would get the whole folder so I could restore to any point in the week.

Now that I am on Veeam 5, it appends the date and other metadata to the file name so I can no longer target the newest backup for my weeknight backups because the file name changes every backup run. Is there a way I can force it to use a clean file name for the base backup like Veeam 4 did?


===
Visual aides (can you tell I am used to writing paint by numbers type documentation for my users? lol)

Backups of the server Paris using Veeam 4:
Image

When setting up my Daily job in BackupExec I can just backup the main file and always have the latest backup:
Image


Now that I am on Veeam 5, the filenames all have metadata attached:
Image

It doesn’t matter if I pick the .VBK file in the selection list because tomorrow the name will change:
Image

I looked around BackupExec and could not find an option to do something like *.VBK so I need to figure out how to standardize the file names, or I need to rethink my strategy
MCoppola
Lurker
 
Posts: 1
Liked: never
Joined: Wed Jul 27, 2011 6:46 pm
Full Name: Mark Coppola

Re: backup naming when using reversed incremental

Veeam Logoby ThomasMc » Fri Jan 20, 2012 6:44 pm

This was requested over twitter but thought I would update this thread incase anyone else find themselves in the same situation

Version: 5
Purpose: Send commands to remote BackupExec Server

Code: Select all
# Remoting must be enabled on the BackupExec Server
# And user must have access to complete task on Veeam and BE

if ((Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue) -eq $null) {
   Add-PsSnapin VeeamPSSnapIn
}

$veeamJobName = "Veeam Job 01"
$backupExecJob = "BackupExec Job 01"
$backupExecSvr = "BackupExec01"
$backupExecPath = "C:\Program Files\Symantec\Backup Exec"

if ((Get-VBRJob | ?{$_.Name -eq $veeamJobName}).GetLastResult() -eq "Success") {
   $latestOib = Get-VBRBackup | ?{$_.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)) {   
      Invoke-Command -ComputerName $backupExecSvr -ScriptBlock {
         param (
            [PSObject]$storage,
            [PsObject]$file,
            [String]$backupExecJob,
            [String]$backupExecPath
            )
         
         & "$backupExecPath\bemcmd.exe" -o2 -j:$backupExecJob -s:$storage.FilePath -m Tapes-Weekdays -r -w
         $file.Attributes = 'Archive'
      } -ArgumentList $storage, $file, $backupExecJob, $backupExecPath
   }
}
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: backup naming when using reversed incremental

Veeam Logoby lcfc » Tue Jun 26, 2012 1:08 am

Raising an old post here but it's relevant to my problem.

I need to backup the last months veeam files of my D2D to tape using BE 2010. I can't use the last accessed date in BE as the files show a recent date and I'd still end up backing up TB's of data that I don't need.

I'm no expert in Powershell but can this script be modified to select say the first 20 files? I did make a quick change to test and it failed - probably because it's only exepecting 1 file?

Method invocation failed because [System.Object[]] doesn't contain a method named 'GetStorage'.
At C:\veeam_scripts\myjob.ps1:9 char:36
+ $storage = $latestOib.GetStorage <<<< ()
+ CategoryInfo : InvalidOperation: (GetStorage:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At C:\veeam_scripts\myjob.ps1:12 char:20
+ $file = get-item <<<< $storage.FilePath
+ CategoryInfo : InvalidData: (:) [Get-Item], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemComm
and

Any help to get this working would be great.
Thanks
Lcfc
lcfc
Novice
 
Posts: 3
Liked: never
Joined: Wed May 18, 2011 2:11 am
Full Name: Gary Davidson

PreviousNext

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 7 guests