Host-based backup of VMware vSphere VMs.
Post Reply
itops
Enthusiast
Posts: 26
Liked: never
Joined: Feb 01, 2018 4:14 pm
Full Name: juan cruz
Contact:

Postthaw script

Post by itops »

Hello, i'm running a cmd script in post-thaw mode for a vm. The script is located in the backup server I needs to run in the VM. These scripts has to delete some files once the backup is done.
I've test it with no luck.

test-script.cmd

Code: Select all

@echo off
set logfile=script.log

echo %DATE% %TIME% - RUNNING SCRIPT >> %logfile%
E:
dir E:\  >> %logfile%
cp %logfile% E:\Temp\
EXIT /b 0
These is a test script but its not generating the log file on E: drive.

How should I do this?
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Postthaw script

Post by PTide »

Hi,

Is that just particular thing that does not work, or the script just does not do anything at all? Any error in the session log?

Thanks!
itops
Enthusiast
Posts: 26
Liked: never
Joined: Feb 01, 2018 4:14 pm
Full Name: juan cruz
Contact:

Re: Postthaw script

Post by itops »

There're no errors. Backup job returns succesfull and the VM log Veeamguesthelper returns OK. But the script is not doing what i expect.
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Postthaw script

Post by PTide »

Code: Select all

cp %logfile% E:\Temp\
Shouldn't it be 'copy' instead?

Thanks
foggy
Veeam Software
Posts: 21069
Liked: 2115 times
Joined: Jul 11, 2011 10:22 am
Full Name: Alexander Fogelson
Contact:

Re: Postthaw script

Post by foggy »

itops wrote: Oct 11, 2018 4:18 pm There're no errors.
This is because it returns 0 in any case, making the job think it finished successfully.
itops
Enthusiast
Posts: 26
Liked: never
Joined: Feb 01, 2018 4:14 pm
Full Name: juan cruz
Contact:

Re: Postthaw script

Post by itops »

PTide wrote: Oct 11, 2018 4:50 pm

Code: Select all

cp %logfile% E:\Temp\
Shouldn't it be 'copy' instead?

Thanks
Yes sorry I make a mistake
itops
Enthusiast
Posts: 26
Liked: never
Joined: Feb 01, 2018 4:14 pm
Full Name: juan cruz
Contact:

Re: Postthaw script

Post by itops »

Where the should be? In the backup server or in the VM? I know that when the script is in the backup server is uploaded to the VM and then executed locally from the VM. But I'm not able to write a file inside de VM and copy somewhere just for testing.
I'm doing something wrong?
Now I'm having exit code 1 with this one

Code: Select all

@echo off
set logfile=C:\tfs-borrado-backups.log
echo %DATE% %TIME% - RUNNING >> %logfile%
copy %logfile% \\remote-path\folder
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Postthaw script

Post by PTide »

Where the should be? In the backup server or in the VM?
On the backup server. Have you tried to run the script manually on VBR server, did it work?

Thanks
itops
Enthusiast
Posts: 26
Liked: never
Joined: Feb 01, 2018 4:14 pm
Full Name: juan cruz
Contact:

Re: Postthaw script

Post by itops »

Yes I executed manually from command prompt on the backup server and it works fine.
itops
Enthusiast
Posts: 26
Liked: never
Joined: Feb 01, 2018 4:14 pm
Full Name: juan cruz
Contact:

Re: Postthaw script

Post by itops »

Basically what i need to do is, after the backup of a VM finishes correctly, then delete files from a folder of the vm. It's simple but I'm not able to do it.
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Postthaw script

Post by PTide »

Then you should use a post-job script instead. Post-thaw script starts right after VM snapshot has been created, not after the backup is completed. Post-job script is executed on VBR after the job is finished, so you'll need to write a script that will be able to login into the VM and perform required actions.

Thanks.
itops
Enthusiast
Posts: 26
Liked: never
Joined: Feb 01, 2018 4:14 pm
Full Name: juan cruz
Contact:

Re: Postthaw script

Post by itops »

I've try to run this with no luck

Code: Select all

@echo off
set logfile=E:\VBR_Scripts\post-bkp\post-bkp-prod-t2.log
echo %DATE% %TIME% >> %logfile%
rem ** TFS **
set logTFS=E:\VBR_Scripts\post-bkp\tfs-borrado-backups.log
echo %DATE% %TIME% - TFS >> %logTFS%
echo test >> %logTFS%
del /F /Q \\tfs\e$\TFS_Backups\*
echo RESULT %errorlevel% >> %logTFS%
echo %DATE% %TIME% - RESULT TFS: %errorlevel% >> %logTFS%

exit /b 0

The output:

Code: Select all

19/10/2018  1:42:36,73 - 
test
RESULT 1 
19/10/2018  1:42:36,75 - RESULT TFS: 1 
But the del command its not working because the files still exist
Which user runs the command? I guess is the appaware processing user, and this user is administrator of the VM where I'm trying to erase files
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Postthaw script

Post by PTide »

As far as I can see from the script, it does not log in into the VM. Post-job script is executed on the VBR server and it won't perform any actions inside a VM unless you've specifically told it to do so. Also I would double-check if 'del' command actually supports deletion from network shares.

Thanks
itops
Enthusiast
Posts: 26
Liked: never
Joined: Feb 01, 2018 4:14 pm
Full Name: juan cruz
Contact:

Re: Postthaw script

Post by itops »

Hello I've execute it using psexec utility and works fine when using a runas command. I don't know which user runs the post-job script. I've to manually setup the credentials and use a plain password but this is not a thing I can really leave as productive.
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Postthaw script

Post by PTide »

For pre/post-job scripts Veeam uses the Service Account under which the Veeam Backup Service is running.

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 78 guests