Comprehensive data protection for all workloads
Post Reply
rhnb
Enthusiast
Posts: 81
Liked: 2 times
Joined: Jan 27, 2010 2:25 pm
Full Name: Allan Nelson
Contact:

Post job activity - copy to tape

Post by rhnb »

Hi
I'm looking at changing our current 'copy Veeam backup to tape' using EMC Networker which we currently do using a bash script on a Linux box hosting the repository. This works fine but isn't as tightly coupled to Veeam as I'd like and could result in timing issues.

I'd like to make use of the post job activity in Veeam to do this to avoid this, and I was thinking I could get this working how I want it if I could get the file name the job used as a parameter to include in the 'command'.

For example lets say my job is called Test and the backup runs creating a file Test2012-09-11T210132.vib. What I'd like to do is issue a savefs command along the lines of...

savefs -l full -g groupname -F {the name of the file used for this backup}

I was wondering if the file name is set as a parameter/environment variable or somesuch that I could use?

I've read the white paper on integrating Veeam and Networker but this assumes you want to do a full backup of the whole 'job' directory.
As we keep a couple of weeks worth of data on the repository (about 20TB), I don't want to do this.
What I'm wanting is to just backup the latest file after each job run.

Any tips on how to achieve this?
Hope this makes sense.
Allan
foggy
Veeam Software
Posts: 21069
Liked: 2115 times
Joined: Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson
Contact:

Re: Post job activity - copy to tape

Post by foggy »

Allan, you can search the backup folder for the file with latest date modified and pass it to this command. Here is an existing topic that allows to pick up the latest file and move it to tapes. You can also search for other similar topics.

Thanks.
rhnb
Enthusiast
Posts: 81
Liked: 2 times
Joined: Jan 27, 2010 2:25 pm
Full Name: Allan Nelson
Contact:

Re: Post job activity - copy to tape

Post by rhnb »

I've almost got what I want working - just one small snag! and I wonder if anyone can help.

On my veeam backup server, I have a BAT file which runs a Powershell script. This in turn runs plink which invokes the save command on my Linux backup server to copy the requested file to tape.
If I run the BAT file manually from a command line on my veeam backup server it all works, so I'm pretty sure all the code is OK, however, when I put it in the Post job section of the job, it doesn't run. I've used full paths wherever files are specified.

So, roughly I run...
C:\VeeamScripts\CopyToTape.bat MyVeeamGroup
This contains...
powershell.exe c:\VeeamScripts\CopyToTape.ps1 %1

The powershell script looks up the latest file for the job it's passed and invokes the bash script on the Linux host e.g.
c:\Putty\plink.exe user@backuphost /veeamscripts/NetworkerCopyToTape MyVeeamjob FullFileSpec

I've configured the necessary public/private keys to allow plink a passwordless login to the Linux host and as I say it all works fine when run manually from the Veeam backup server.

I've done it this way so that I only need 1 BAT file and 1 Powershell file on the veeam backup server, as in the Post job script window, I can add the job name as a parameter to the BAT file e.g.

I'm 'guessing' it's something to do with passing the parameter initially to the batch file.
Can anyone confirm, in the Post job script window what the necessary quotes might be?

I think I've tried them all e.g.
No quotes
"C:\VeeamScripts\CopyToTape.bat" Jobname
"C:\VeeamScripts\CopyToTape.bat Jobname"

Any help much appreciated as it's almost there!
Cheers... Allan.
foggy
Veeam Software
Posts: 21069
Liked: 2115 times
Joined: Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson
Contact:

Re: Post job activity - copy to tape

Post by foggy »

Check out this one, should give some ideas...
rhnb
Enthusiast
Posts: 81
Liked: 2 times
Joined: Jan 27, 2010 2:25 pm
Full Name: Allan Nelson
Contact:

Re: Post job activity - copy to tape

Post by rhnb »

Me again
Still no joy I'm afraid.

I've tried this very simple test...
TEST.BAT contains
powershell.exe "c:\test.ps1"

TEST.PS1 contains
& "c:\plink.exe" user@linuxhost "touch rubbish"

If I run this manually, the file rubbish is created on the host Linuxhost at the home directory of the user 'user'.

If I add the BAT file as a post job command and run the job, the file does not get created.

If I modify TEST.PS1 to run a simple batch file to create a file locally on the Veeam server, then it works.
So, it looks as though it doesn't like running plink.exe for some reason when run from a Veeam job.

The job is running under the Administrator account (as is the Veeam B&R service) on a Windows2008R2 server.

Really stuck with this now. Anyone any ideas what might be wrong? So frustrating as it's working fine when run manually.
foggy
Veeam Software
Posts: 21069
Liked: 2115 times
Joined: Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson
Contact:

Re: Post job activity - copy to tape

Post by foggy »

Most likely the issue is in the service account that cannot access the target drive (even if it is the same admin account - like the service cannot see the mapped drives as they can only be used while you're logged to the machine interactively). Try to find out how to execute this kind of command under service account (maybe specifying FQDN or IP of the Linux server will help).
rhnb
Enthusiast
Posts: 81
Liked: 2 times
Joined: Jan 27, 2010 2:25 pm
Full Name: Allan Nelson
Contact:

Re: Post job activity - copy to tape

Post by rhnb »

Thanks for persevering with me foggy.
I've found the problem - it's now getting the solution.

As I mentioned I'm using plink to execute the command remotely.
As I don't want to have passwords in the Powershell file, I've got public/private keys configured (using the Administrator account).

If I include the Linux username and password in the powershell script, all works fine.
If I use the user@host syntax (so it should use the keys) then it doesn;t work and I 'think' that's because for some reason, though I'm logging in as Administrator and the Veeam service is shown as using .\administrator, I don;t think it's regarding them as the same and so it can't use the keys :-(

I thought coping the keys out of the registry to HKEY_USERS\.DEFAULT.... would do the trick, but that doesn't work either.
I think I need to pop off to a Windows/Linux forum to see if I can get this resolved.
Thanks again for your help, and if you have any ideas, I'm all ears!
Cheeers... allan.
dellock6
VeeaMVP
Posts: 6137
Liked: 1928 times
Joined: Jul 26, 2009 3:39 pm
Full Name: Luca Dell'Oca
Location: Varese, Italy
Contact:

Re: Post job activity - copy to tape

Post by dellock6 »

In Powershell you can encrypt credentials in a cypher text file with Get-Credentials and then call the file during script executions.

Luca.
Luca Dell'Oca
Principal EMEA Cloud Architect @ Veeam Software

@dellock6
https://www.virtualtothecore.com/
vExpert 2011 -> 2022
Veeam VMCE #1
rhnb
Enthusiast
Posts: 81
Liked: 2 times
Joined: Jan 27, 2010 2:25 pm
Full Name: Allan Nelson
Contact:

Re: Post job activity - copy to tape

Post by rhnb » 2 people like this post

Just to complete this query in case anyone else has the problem.
I now have it working. The problem was that 'pageant' the key handling utility that comes with the PuTTY suite does not (and cannot) run as a windows service and so while I could run the scripts happily from the console, when Veeam came to run them it couldn't connect as there was nothing to take care of the authentication.
Easily fixed by using the -i option of plink to point it at the private key file. So, my full Powershell command is (I've used variables but this gives the idea)...

Code: Select all

& "C:\VeeamScripts\plink.exe"  -ssh -batch -i C:\VeeamScripts\myppkfile user@linuxhost  echo "linuxscript  veeamfilespec | at now +1 minutes
Works like a champ.

For info, I've found using 'at' to queue the job is a good idea. It means the Veeam job is not held up while the tape copying takes place and control is returned immediately the command is queued and the the job is finished.

Thanks for listening!
Vitaliy S.
VP, Product Management
Posts: 27055
Liked: 2710 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Post job activity - copy to tape

Post by Vitaliy S. »

Thanks for sharing your solution with the community!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 251 guests