backup naming when using reversed incremental

PowerShell script exchange

backup naming when using reversed incremental

Veeam Logoby joergr » Tue Oct 26, 2010 1:58 pm

Hi,

an important question for me personally, with 4.x i used to Backup a fullbackup (the latest vbk) to tape every night. I did this by just telling my tape software to backup the "backupjob.vbk" file, because even if i made full backups during some weekdays, the final and most actual backup would always has THIS name.

Now with v5 i have a little problem here: Even if i select reversed increment (which is what i want and which is the v4 way), it would add the date and the time to the latest vbk backup file. Thus I cannot tell my tape backup software to backup THIS special file every night because every time a backup runs this name will change.

Is there some way out for me? ;-) Any idea to tell a tape software to backup the latest full backup without storing all the reverse increments? Or any tweak to have the naming convention fall back to the v4 way?

best regards,
Joerg
joergr
Expert
 
Posts: 377
Liked: 39 times
Joined: Tue Jun 08, 2010 2:01 pm
Full Name: Joerg Riether

Re: backup naming when using reversed incremental

Veeam Logoby Gostev » Tue Oct 26, 2010 3:34 pm

Hi Joerg, you can use the following PowerShell script as post-backup action, this will work for any backup mode, and will copy the latest backup file to tape (whatever the latest backup file is) and set archive bit on it. Just put the backup job name, and customize path and any arguments for tape backup EXE.

Code: Select all
Add-PSSnapin VeeamPSSnapIn

$jobName = "Put Backup Job Name Here"

if ((Get-VBRJob | where {$_.Name -eq $jobName}).GetLastResult() -eq "Success")
{
   $latestOib = Get-VBRBackup | where {$_.JobName -eq $jobName} | 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))
   {
     $path_to_tape_backup_exe $storage.FilePath
     
      $file.Attributes = ($file.Attributes -bxor [System.IO.FileAttributes]::Archive)
   } 
}
Gostev
Veeam Software
 
Posts: 21385
Liked: 2348 times
Joined: Sun Jan 01, 2006 1:01 am
Location: Baar, Switzerland

Re: backup naming when using reversed incremental

Veeam Logoby joergr » Tue Oct 26, 2010 4:12 pm

muchas gracias ;-)
joergr
Expert
 
Posts: 377
Liked: 39 times
Joined: Tue Jun 08, 2010 2:01 pm
Full Name: Joerg Riether

Re: backup naming when using reversed incremental

Veeam Logoby itldn » Tue May 31, 2011 4:04 pm

Hi,

Did anyone managed to use the above script?

I am finding some troubles running this script, i have changed the job name and the backup exec file path but when i run the backup then backup complete fine but thats it, no backup exec job running.

i have modified the script as follow

Code: Select all
Add-PSSnapin VeeamPSSnapIn

    $jobName = "DMZ-test"

    if ((Get-VBRJob | where {$_.Name -eq $jobName}).GetLastResult() -eq "Success")
    {
       $latestOib = Get-VBRBackup | where {$_.JobName -eq $jobName} | 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" -o1 -jdmztest $storage.FilePath
         
          $file.Attributes = ($file.Attributes -bxor [System.IO.FileAttributes]::Archive)
       }
    }

this script was saved as powershell .ps1

i have tested the following line from the command line and the backup exec job starts fine
"d:\Program Files\Symantec\Backup Exec\bemcmd" -o1 -jdmztest

but if i open the Windows Powershell Module window and type the full path to the script file then i have the following error

"

You must provide a value expression on the right-hand side of the '-' operator.
At D:\copytotape.ps1:18 char:58
+ "d:\Program Files\Symantec\Backup Exec\bemcmd" - <<<< o1 -jdmztest $storage.FilePath
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : ExpectedValueExpression

"

i don't understand why it is complaining about the arguments whereas if i run it through the DOS CMD then it is fine.

can anyone help?

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. » Wed Jun 01, 2011 8:56 am

Could you please modify your script in the following way:
Code: Select all
...
"d:\Program Files\Symantec\Backup Exec\bemcmd -o1 -jdmztest"
...

Does it work?
Vitaliy S.
Veeam Software
 
Posts: 19536
Liked: 1097 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 01, 2011 9:19 am

No did not work - it was complaining about the next variable $storage.FilePath so i included it to the quote so my line now looks like
"d:\Program Files\Symantec\Backup Exec\bemcmd -o1 -jdmztest $storage.FilePath"

This i think has worked although no Backup Exec job has started but the output of the Powershell widows indicates that could not add veeam snap-in
see below


Code: Select all
PS C:\Windows\system32> D:\copytotape.ps1
Add-PSSnapin : Cannot add Windows PowerShell snap-in VeeamPSSnapIn because it is already added. Verify the name of
snap-in and try again.
At D:\copytotape.ps1:2 char:13
+ Add-PSSnapin <<<<  VeeamPSSnapIn
    + CategoryInfo          : InvalidArgument: (VeeamPSSnapIn:String) [Add-PSSnapin], PSArgumentException
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand



Info              : Veeam.Backup.Model.COibInfo
Id                : a373ad08-1f5b-4e39-bba4-74dac094dd1a
CreationTime      : 31/05/2011 16:44:55
CreationTimeUtc   : 31/05/2011 15:44:55
Type              : Increment
Algorithm         : Increment
PointId           : e92ae8aa-7238-4645-b384-dfa325e7d90d
ObjectId          : 2e4ff73a-de8a-4615-ba70-deecffea4dc6
StorageId         : d7c0b65e-631c-4f2c-b05e-38f143b85b11
InsideDir         : ff7bb930-f879-4a76-8173-11b05dba566a (vm-797)
IsFailoved        : False
IsCorrupted       : False
IsConsistent      : True
ApproxSize        : 42949672960
VmName            : DMZ-test
EffectiveMemoryMb : 4096
GuestInfo         : Veeam.Backup.Model.CGuestInfo
ProcessID         : -1
AuxData           : Veeam.Backup.Core.COibAuxDataVmware

D:\test\DMZ-test\DMZ-test2011-05-31T164449.vib
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. » Wed Jun 01, 2011 9:37 am

Nile,

In order to avoid such errors, you may want to modify your script with something like this. As to the BE job not running, try to execute any other simple script just to check whether it is triggered or not.

Thanks.
Vitaliy S.
Veeam Software
 
Posts: 19536
Liked: 1097 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 01, 2011 9:55 am

I am assuming that the error is not important as the link you have send me is just define it as Silent continue in other word just ignore the error. As long as veeam snap in is started then i don't care but how do i check if the snap-in has started.

As per the BE - you suggestion to try simple script; do you mean PowerShell script (which i have no experience but will try) or did you mean .bat files cus as i said before i can start backup exec job from the DOS-CMD by just calling
"d:\Program Files\Symantec\Backup Exec\bemcmd" -o1 -jdmztest
as you can see the ending quotes is in differen place than the one in PowerShell script.

If the problem is with the powerShell script then i am just wondering has this been tested before been published or is there anyone was successfull with this Powershell script?

Thanks for your help.
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. » Wed Jun 01, 2011 10:52 am

As far as I see it from the forums this functionality has been used pretty often and so far we've received no negative feedback.

The reason why I've asked you to perform a simple script check (bat file will be enough) is that your BE script might not be executed as a post backup job script due to these reasons (even if you are able to launch it interactively).

If this is not the case and everything looks good, please reach our technical team for further troubleshooting steps.
Vitaliy S.
Veeam Software
 
Posts: 19536
Liked: 1097 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 01, 2011 11:30 am

i can confirm the Post backup job script (bat file) runs good and the BE job runs as well. As i mentioned before It seems to me that the PowerShell Script has problems or my environment is missing something - i am running the backup exec 2010R2 on windows server 2008R2 and veeam running on the same server.

I am afraid that if i contact Veeam support i will be turned down as this is to do with the Powershell script and BE.

have we reached a closed door in this forum? is there anyone else can add something?
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. » Wed Jun 01, 2011 1:40 pm

I'm not a PS expert, but I've googled further...

Could this issue be related to arguments with spaces and quotes triggering in a different way with PowerShell?
http://stackoverflow.com/questions/1673967/how-to-run-exe-in-powershell-with-parameters-with-spaces-and-quotes
http://www.powershell.nu/2009/12/16/running-scripts-with-arguments-in-powershell/

Another way out might be specifying a batch file or another PS script (which will trigger BE job) instead of using BE job cmdlet directly, worth trying...
Vitaliy S.
Veeam Software
 
Posts: 19536
Liked: 1097 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 01, 2011 3:42 pm

Hi Vitaliy,

I have found the above link as well but the problem is the missing &

the line should be like this

& "d:\Program Files\Symantec\Backup Exec\bemcmd.exe" -o1 -jdmztest $storage.FilePath

i am surprise no one has spotted this syntax error!!

However this has fixed the problem if i run the PS file from the PS command, But if i added to the Post backup job in veeam then it does not do anything!!!

I am just going to try to run it from bat file as i dont know if veeam can run PS1 files
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. » Wed Jun 01, 2011 3:55 pm

Nile, thanks for an update and for catching a syntax error! Just fixed it. Let me know how the bat file works for you.
Vitaliy S.
Veeam Software
 
Posts: 19536
Liked: 1097 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: backup naming when using reversed incremental

Veeam Logoby itldn » Thu Jun 02, 2011 10:33 am

This script unfortunately is still not working; after fixing the syntax error, i am still not able to run this script from within veeam (Post job), this probably due to Veeam not able to run PS files.
So I tried to get the PS file to run from BAT file - This also has failed due to using Veeam custom functions like (Get-VBRBackup) that bat file does not understand.

so i am really stuck with this and i hope that Gostev (who wrote the script) or any other member who is using this script that works for them to share with all of us

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

Re: backup naming when using reversed incremental

Veeam Logoby itldn » Thu Jun 02, 2011 1:06 pm

Ok guys - got it working!!

I can now confirm that Veeam is not able to run PS file from its post-backup script.
what you need to do is the following
1. Create the PS (e.g. test.ps1)file that was mentioned above (dont forget to get the Syntax write - you need the & for the file to work see above)
2. Create a BAT (e.g test2.bat)file that should include the following
powershell.exe FileNameIncludePath e.g assuming the PS file is in the root of C:\ then your code should be powershell.exe c:\test1.ps1
3. On veeam Post-job activity browse to the test2.bat

all done - this should backup the file then runs the post script which in turn will run BE job

Regards,

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

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 7 guests