Thursday, April 16, 2009

How to schedule a GhettoVCB backup job or any other script you want

Hi folks, in order to schedule the GhettoVCB backup script you will need to use the program Plink.exe I spoke about in my previous post.

First download the Plink.exe program and place it in a folder on your server. I create a directory on the C drive called putty and place plink.exe in c:\putty. Then create a batch file using notepad called ghettoVCB.bat.

My batch file assumes the following things for the sake of this example:

  • The ESXi servers IP address is
  • The username is root to login
  • The root password is mypassword
  • backuplog.txt is the name of the text file where the output of the commands will be sent
Now edit the ghettoVCB.bat file and enter the following line on one line, I usually turn word wrap off in Notepad, substitute the values for your own values:

c:\putty\plink.exe root@ -pw mypassword “nohup ./vmfs/volumes/datastore1/ /vmfs/volumes/datastore1/vmwarebackups > /vmfs/volumes/datastore1/backuplog.txt &”

Create a windows scheduled task now and point it at the batch file and schedule it to run at whatever interval you like. You now have a scheduled backup job for ESXi!



Ken said...

First of all thanks for the info!

Plink is executing the script perfectly but the backuplog.txt is empty. It is creating the file but nothing is being written to it.

any ideas?

Ronald said...

it doesnt work for me :(

Piet said...

Thx for this great guide Raj! Only problem I'm left with is (as said above) the backuplog.txt. After the job finishes it's still 0 kb. The backuplog is being stored on the NFS location.

If you have any idea what might be wrong please share ;-)

@Ronald: what does not work exactly? Did you try executing the .bat in cmd to see what errors it generates?

Ronald said...

Hi Piet,

It just wont work for me. It wont create the backup at all.

I tried to run the batch file on cmd and it says "the system cannot find the path specified"

I just followed everything what Raj has instructed.

When i had that error, i put the .bat file and plink from where my CMD path is, and i tried to run it again and this time no error, i was able to generate the log file now, but the backup still wont show up on the backup drive or anywhere else.

I've been trying to figure this out for more than a week now.
Can you help please?

Piet said...

Hi Ronald,

There are 2 things you need to check:
-First: Try editing the bat file in the DOS editor ( when in cmd type "edit ghettoVCB.bat"
This way you can fix the characters/path that might have been altered when you typed them in notepad. I had this problem for example with my password and also the qoute (") characters in the command.

-Second: check the line where you specify the file that needs for the hosts. Because Raj posted in his previous posts that he used the name "vmbackups" as the hosts file the above line will not work (note that he uses "vmwarebackups"). This will result in the problem you posted above, only a backuplog.txt without any actual backups. So you need to edit the vmwarebackups to vmbackups (in case that this has not been changed yet).

If this works, please let us know if your backuplog is also 0 kb.

Ronald said...

Hi Piet,

I did change the host file to the host file that i created. It's all been changed according to my settings and still doesnt work.

I will try editing the bat file and see how it goes this time.


Ronald said...

still doesnt work. I only get the log file with 0KB. I still cant backup. I've tried everything.

btw, on my bat file i omit c:\plink as the bat file is already located at the same path where my plink.exe is. so its only plink.exe root@...etc..

am i doing something wrong?

if i try to put c:\plink it says the command c:\plink is not recognised or soemthing

Piet said...

Hi Ronald,

That is odd. Mine works fine with: c:\putty\plink.exe (as described in the guide). I let it that way even though my bat file is also already located in the c:\putty folder.

Csabo2 said...

I'm getting "ash: (a divide sign): not found

obsidian said...

The backup and everything else runs great, backuplog.txt is empty. Ideas?

Wolfgang said...

same here, backup works but backuplog.txt is empty!

Post a Comment