0

I have a Shell Script under which restore command is mentioned for restoring the DB from target folder. My File name will be mongorestore.sh

NOTE: Dump data location will be E:Backup/test

#!/bin/sh
DEST="Location where my backup is stored"
mongorestore -h 127.0.0.1:27021 -d secondary "E:Backup/test/dbname"

NOTE: If I will double-click on this shell file then it will restore the backup. But it will not be done through schedule task. Schedule Task CMD will Open And then Instantly closed. Not able to get the error also. Already Checked on Schedule task log file but there is no error.

And I will Create the Schedule task for invoking this file for creating the restore process. But it will not do. Even I am not able to see the error. As it open and instant close. If anyone has any idea regarding this?

And please check whether my command will be right or not. Any help is really appreciated.

My mongodump Script file will be:

#!/bin/sh
DIR=`date +%m%d%y`
DEST="E:Backup/test/$DIR"
mkdir $DEST
mongodump -h 127.0.0.1:27017 -d myDbName -o $DEST

It was working fine

  • Your mongorestore is not in then $PATH. And how your restore path can start with E:Backup, never seen at *nix that kind of path. – JJussi Feb 8 '18 at 20:35
  • @JJussi I updated the Question. Please go through it if you can. – Ankit Feb 9 '18 at 5:17
  • Still my answer is PATH missing. Simple, your environment is not same when you use task schedule and when you click as a user that batch file. So, add full path to mongorestore command c:/something/somewhere/mongorestore AND to that E:Backup E:/somewhere/Backup/dbname – JJussi Feb 9 '18 at 5:26
  • @JJussi but the same process I was done with mongoDump. and there is no problem while creating the backup. – Ankit Feb 9 '18 at 5:45
  • 1
    any reason for use Bash script for Windows MongoDB? and think @JJussi give a proper answer – a_vlad Feb 9 '18 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.