Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Backup Batch File Problem


  • Please log in to reply
14 replies to this topic

#1 swingarm

swingarm

  • Members
  • 14 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Northern Colorado
  • Local time:03:07 AM

Posted 24 December 2016 - 05:23 AM

Here is the batch file:

 

@echo off
k:
cd Batch_Files
server.bat > batchlog.log
timeout /t 2 /NOBREAK
"C:\Program Files\FastCopy\FastCopy.exe" /cmd=force_copy /error_stop=FALSE /force_close /acl=FALSE "k:\batchlog.log" /to="\\buffalo\share\os_images\Server"
exit
 
This will be in Windows 10 and 2012 r2 Essentials Server.  Problem is that in line 4 it runs it then moves on immediately which causes problem for the other batch file(server.bat).  I need line 4 to run but not move on till that batch file(server.bat) is done.  I need to keep line 4 intact whatever happens.  I've tried using various forms of the START and CALL command with no luck.  I've Googled my brains out for about 5 hours on this and I'm hoping someone has a suggestion I haven't thought about.  Maybe I'm missing something really simple.


BC AdBot (Login to Remove)

 


#2 bwv848

bwv848

    Bleepin' Owl


  • BSOD Kernel Dump Expert
  • 3,028 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:92.96 million miles away from the sun
  • Local time:06:07 AM

Posted 24 December 2016 - 04:09 PM

Would you please share your other batch file? Thank you.

 

Edit: Actually you're not supposed to use redirection symbols with the CALL command ... could be the cause of your problem:

 

Do not use pipes (|) and redirection symbols (< or >) with call.


Edited by bwv848, 24 December 2016 - 04:43 PM.

If I do not reply in three days, please message me.
 
BC BSOD Posting Instructions | Carrona BSOD Index | Driver Reference Table (DRT)


#3 swingarm

swingarm
  • Topic Starter

  • Members
  • 14 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Northern Colorado
  • Local time:03:07 AM

Posted 24 December 2016 - 05:43 PM

server.bat file:

 

@echo on
time /t
date /t 
timeout /t 2 /NOBREAK
REM Delete main WindowsImageBackup
"C:\Program Files\FastCopy\FastCopy.exe" /cmd=delete /no_confirm_del /error_stop=FALSE /force_close "k:\WindowsImageBackup"
timeout /t 4 /NOBREAK
REM Pause FAHClient
cd "c:\Program Files (x86)\FAHclient"
FAHclient.exe --send-pause
timeout /t 4 /NOBREAK
REM Backup Server OS
schtasks /run /TN "\Microsoft\Windows\Backup\Microsoft-Windows-WindowsBackup" 
timeout /t 1200 /NOBREAK
time /t
date /t
REM Unpause FAHClient
FAHclient.exe --send-unpause
timeout /t 4 /NOBREAK
REM Delete remote WindowsImageBackup and log
"C:\Program Files\FastCopy\FastCopy.exe" /cmd=delete /no_confirm_del /error_stop=FALSE /force_close "\\buffalo\share\os_images\Server\*"
timeout /t 3 /NOBREAK
REM Copy main WindowsImageBackup to remote storage
"C:\Program Files\FastCopy\FastCopy.exe" /cmd=force_copy /log /filelog="\\buffalo\share\os_images\Server\servercopy.log" /error_stop=FALSE /force_close /acl=FALSE "k:\WindowsImageBackup" /to="\\buffalo\share\os_images\Server\WindowsImageBackup"
time /t
date/t
exit
 
 
Hmmm, now I know.  No redirection symbols within Call.

Edited by swingarm, 24 December 2016 - 05:46 PM.


#4 RolandJS

RolandJS

  • Members
  • 4,533 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Austin TX metro area
  • Local time:05:07 AM

Posted 24 December 2016 - 07:11 PM

Did you get it working?


"Take care of thy backups and thy restores shall take care of thee."  -- Ben Franklin revisited.

http://collegecafe.fr.yuku.com/forums/45/Computer-Technologies/

Backup, backup, backup! -- Lady Fitzgerald (w7forums)

Clone or Image often! Backup... -- RockE (WSL)


#5 bwv848

bwv848

    Bleepin' Owl


  • BSOD Kernel Dump Expert
  • 3,028 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:92.96 million miles away from the sun
  • Local time:06:07 AM

Posted 24 December 2016 - 09:11 PM

I just tested out your batch file sequence on my computer, and it worked fine. All I did was add the CALL command; in fact, I managed to use redirection symbols too. If you still haven't been able to figure out the problem, please try this:

@echo off
k:
cd Batch_Files
CALL "server.bat" > "batchlog.log"
timeout /t 2 /NOBREAK
"C:\Program Files\FastCopy\FastCopy.exe" /cmd=force_copy /error_stop=FALSE /force_close /acl=FALSE "k:\batchlog.log" /to="\\buffalo\share\os_images\Server"
exit /B

Any luck? Thank much. :)

 

Edit: Please delete exit from your second batch file too:

@echo on
time /t
date /t 
timeout /t 2 /NOBREAK
REM Delete main WindowsImageBackup
"C:\Program Files\FastCopy\FastCopy.exe" /cmd=delete /no_confirm_del /error_stop=FALSE /force_close "k:\WindowsImageBackup"
timeout /t 4 /NOBREAK
REM Pause FAHClient
cd "c:\Program Files (x86)\FAHclient"
FAHclient.exe --send-pause
timeout /t 4 /NOBREAK
REM Backup Server OS
schtasks /run /TN "\Microsoft\Windows\Backup\Microsoft-Windows-WindowsBackup" 
timeout /t 1200 /NOBREAK
time /t
date /t
REM Unpause FAHClient
FAHclient.exe --send-unpause
timeout /t 4 /NOBREAK
REM Delete remote WindowsImageBackup and log
"C:\Program Files\FastCopy\FastCopy.exe" /cmd=delete /no_confirm_del /error_stop=FALSE /force_close "\\buffalo\share\os_images\Server\*"
timeout /t 3 /NOBREAK
REM Copy main WindowsImageBackup to remote storage
"C:\Program Files\FastCopy\FastCopy.exe" /cmd=force_copy /log /filelog="\\buffalo\share\os_images\Server\servercopy.log" /error_stop=FALSE /force_close /acl=FALSE "k:\WindowsImageBackup" /to="\\buffalo\share\os_images\Server\WindowsImageBackup"
time /t
date/t

Edited by bwv848, 24 December 2016 - 11:03 PM.

If I do not reply in three days, please message me.
 
BC BSOD Posting Instructions | Carrona BSOD Index | Driver Reference Table (DRT)


#6 swingarm

swingarm
  • Topic Starter

  • Members
  • 14 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Northern Colorado
  • Local time:03:07 AM

Posted 25 December 2016 - 12:19 AM

First, thanks to all that replied to my initial post.

 

Ok bwv848 I tried yours and it still exited after running that line.  I started thinking then and saw that it was opening only one cmd window and the reason it was exiting right after that command was because the second batch file(server.bat) was running in that window and it was just obeying the batch file by exiting and closing the cmd window.  I then figured I need to have server.bat open and run in the second cmd window, after experimenting I came up with this command:

 

start /wait cmd.exe @CMD /K "server.bat > k:\batchlog.log & exit" 

 

First batch file starts in first window and opens(starts) second batch file in new cmd window.  When second batch file is done it exits and closes second cmd window.  First batch file then finishes then exits the first cmd window.

 

Now if I could get the second batch file to output to the cmd window AND a log file at the SAME TIME but that's a different post if I think it's important.



#7 bwv848

bwv848

    Bleepin' Owl


  • BSOD Kernel Dump Expert
  • 3,028 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:92.96 million miles away from the sun
  • Local time:06:07 AM

Posted 25 December 2016 - 05:19 PM

I have to say that this is a weird problem that I've never come across. The call command, when invoked in a batch file (#1), is supposed to execute another batch file (#2) while pausing the batch file that it was executed from (#1). I edited the second batch file so that it will be the one creating the log, not the first one. No guarantee this will work, but please give this a shot:

 

Batch File 1:

@echo off
k:
cd Batch_Files
CALL server.bat
timeout /t 2 /NOBREAK
"C:\Program Files\FastCopy\FastCopy.exe" /cmd=force_copy /error_stop=FALSE /force_close /acl=FALSE "k:\batchlog.log" /to="\\buffalo\share\os_images\Server"
exit /B

Batch File 2:

@echo on
>bathlog.log (
	time /t
	date /t
	timeout /t 2 /NOBREAK
	REM Delete main WindowsImageBackup
	"C:\Program Files\FastCopy\FastCopy.exe" /cmd=delete /no_confirm_del /error_stop=FALSE /force_close "k:\WindowsImageBackup"
	timeout /t 4 /NOBREAK
	REM Pause FAHClient
	cd "c:\Program Files (x86)\FAHclient"
	FAHclient.exe --send-pause
	timeout /t 4 /NOBREAK
	REM Backup Server OS
	schtasks /run /TN "\Microsoft\Windows\Backup\Microsoft-Windows-WindowsBackup" 
	timeout /t 1200 /NOBREAK
	time /t
	date /t
	REM Unpause FAHClient
	FAHclient.exe --send-unpause
	timeout /t 4 /NOBREAK
	REM Delete remote WindowsImageBackup and log
	"C:\Program Files\FastCopy\FastCopy.exe" /cmd=delete /no_confirm_del /error_stop=FALSE /force_close "\\buffalo\share\os_images\Server\*"
	timeout /t 3 /NOBREAK
	REM Copy main WindowsImageBackup to remote storage
	"C:\Program Files\FastCopy\FastCopy.exe" /cmd=force_copy /log /filelog="\\buffalo\share\os_images\Server\servercopy.log" /error_stop=FALSE /force_close 	/acl=FALSE "k:\WindowsImageBackup" /to="\\buffalo\share\os_images\Server\WindowsImageBackup"
	time /t
	date/t
)

Sorry if the formatting got messed up! Thank you and Merry Christmas! :santa:


Edited by bwv848, 25 December 2016 - 09:55 PM.

If I do not reply in three days, please message me.
 
BC BSOD Posting Instructions | Carrona BSOD Index | Driver Reference Table (DRT)


#8 swingarm

swingarm
  • Topic Starter

  • Members
  • 14 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Northern Colorado
  • Local time:03:07 AM

Posted 25 December 2016 - 05:32 PM

Yeah, short answer is the problem wasn't the use or non-use of the Call command.   Also mentioned in this thread was I couldn't use redirection symbols with the Call command and the main line in the first batch file had one(>), I tried to find an alternative to using it but no dice.

 

Oh, and Merry Christmas to you also!


Edited by swingarm, 25 December 2016 - 05:43 PM.


#9 bwv848

bwv848

    Bleepin' Owl


  • BSOD Kernel Dump Expert
  • 3,028 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:92.96 million miles away from the sun
  • Local time:06:07 AM

Posted 25 December 2016 - 05:37 PM

So did my batch file work? :wink:


If I do not reply in three days, please message me.
 
BC BSOD Posting Instructions | Carrona BSOD Index | Driver Reference Table (DRT)


#10 swingarm

swingarm
  • Topic Starter

  • Members
  • 14 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Northern Colorado
  • Local time:03:07 AM

Posted 25 December 2016 - 09:53 PM

No I haven't but I will in the next 2-3 days.  I'll say this right off that's a solution I didn't see in all my hours of Googling.



#11 bwv848

bwv848

    Bleepin' Owl


  • BSOD Kernel Dump Expert
  • 3,028 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:92.96 million miles away from the sun
  • Local time:06:07 AM

Posted 25 December 2016 - 09:56 PM

No problem. :) I'll wait for the results. Enjoy your Christmas weekend!


If I do not reply in three days, please message me.
 
BC BSOD Posting Instructions | Carrona BSOD Index | Driver Reference Table (DRT)


#12 swingarm

swingarm
  • Topic Starter

  • Members
  • 14 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Northern Colorado
  • Local time:03:07 AM

Posted 26 December 2016 - 02:45 AM

Ok, bwv848, I tried it and it did work.  Now I have to decide between the two, lol.



#13 bwv848

bwv848

    Bleepin' Owl


  • BSOD Kernel Dump Expert
  • 3,028 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:92.96 million miles away from the sun
  • Local time:06:07 AM

Posted 26 December 2016 - 09:25 AM

Alright, great. So the first batch file doesn't automatically move on after executing the second one, which means everything is working as it should? (Also a log file is created?):)

Edited by bwv848, 26 December 2016 - 09:32 AM.

If I do not reply in three days, please message me.
 
BC BSOD Posting Instructions | Carrona BSOD Index | Driver Reference Table (DRT)


#14 swingarm

swingarm
  • Topic Starter

  • Members
  • 14 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Northern Colorado
  • Local time:03:07 AM

Posted 26 December 2016 - 09:16 PM

Alright, great. So the first batch file doesn't automatically move on after executing the second one, which means everything is working as it should? (Also a log file is created?) :)

 

Yep, I checked everything and it works just fine



#15 bwv848

bwv848

    Bleepin' Owl


  • BSOD Kernel Dump Expert
  • 3,028 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:92.96 million miles away from the sun
  • Local time:06:07 AM

Posted 26 December 2016 - 11:25 PM

Fantastic! Glad we could help... please let us know if you encounter more problems. :)


If I do not reply in three days, please message me.
 
BC BSOD Posting Instructions | Carrona BSOD Index | Driver Reference Table (DRT)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users