I have a .bat file S:\BACKUP_db\copytofileserver.bat, which takes some files and zip them to the network drive. Its first command is to delete the old backup at specific network path, then pack the files in S:\BACKUP_db folder. See:
echo ================================================== >> log.txt echo %date%, %time%: Backup started >> log.txt set dow=%date:~0,3% >> log.txt echo %time%: deleting existing backup... >> log.txt del /F /S /Q /A "\\192.168.1.249\homes\backup\%dow%.7z" >> log.txt echo %time%: OK >> log.txt echo %time%: packing and saving new backup... >> log.txt if exist *.Backup S:\BACKUP_db\7za a -t7z -mx=1 "\\192.168.1.249\homes\backup\%dow%.7z" S:\Backup_db\*.Backup -m0=BCJ2 -m1=LZMA:d23 -m2=LZMA:d19 -m3=LZMA:d19 -mb0:1 -mb0s1:2 -mb0s2:3 >> log.txt echo %time%: OK >> log.txt echo %time%: deleting local backup files... >> log.txt del /F /S /Q /A S:\backup_db\*.Backup >> log.txt echo %time%: OK >> log.txt echo %date%, %time%: Backup finished >> log.txt
when I run this .bat file manually, it works like a charm (file is very big, cca 50 GB, when zipped it has cca 5 GB), however when I run this .bat file in windows scheduler job, it starts ok, deletes files in network location but then it is always stuck during execution of 7zip program. Windows scheduler says last run result= 0x41306.
Settings of the windows scheduler task seem correct: run only when user is logged on, "run with highest privileges" doesn't make a difference, etc.
Strange is, it worked before, now it is getting stuck and I have no idea why. Sometimes a 16MB zipped file is created at network destination, sometimes 2GB file, it seems random.
second round: well, this is what happend now - I set the bat file to run at specified time and observed black window with my commands being executed. It crashed again, the file was created: "\192.168.1.249\homes\qi\BackupQIostra\po .7z", it has 0.6 GB, it is supposed to have at least 5 GB. Also in the bat file I substituted all local paths with "%~dp0" as suggested, no change. Log file output:
================================================== po 04. 08. 2014, 11:00:00,40: Backup started 11:00:00,44: deleting existing backup... Deleted file - \\192.168.1.249\homes\backup\po .7z 11:00:00,49: OK 11:00:00,50: packing and saving new backup...
after this, I run the .bat file by double-click and observed what happens, zipping goes well, 5 GB file is created, log output is complete:
================================================== po 04. 08. 2014, 11:37:37,60: Backup started 11:37:37,61: deleting existing backup... Deleted file - \\192.168.1.249\homes\backup\po .7z 11:37:37,63: OK 11:37:37,63: packing and saving new backup... 7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 Scanning Creating archive \\192.168.1.249\homes\backup\po .7z Compressing 20225_20140804030000 - Copy.Backup Compressing 20225_20140804030000.Backup Everything is Ok 12:53:59,52: OK 12:53:59,52: deleting local backup files... Deleted file - S:\BACKUP_db\20225_20140804030000 - Copy.Backup Deleted file - S:\BACKUP_db\20225_20140804030000.Backup 12:54:02,18: OK po 04. 08. 2014, 12:54:02,18: Backup finished