
problem s bat suborom
Dobrý den,
mam taky divny problem. Vytvoril som si batacik, co mi zalohuje sietove disky na moj lokalny disk. Dal som ho spustat cez sheduler vzdy o 1 v noci. Dost divne je ze ked idem cas od casu premazat zalohu tak pre disk F je tam vzdy iba aktualna zaloha z dnesneho dna. Starsie zalohy nechapem kam sa vyparia
vypis z adresaru vyzera asi takto:
zalohaF16.02.2009.zip
zalohaG08.02.2009.zip
zalohaG10.02.2009.zip
zalohaG11.02.2009.zip
zalohaG13.02.2009.zip
zalohaG14.02.2009.zip
zalohaG15.02.2009.zip
zalohaG16.02.2009.zip
zalohaG30.01.2009.zip
zalohaG31.01.2009.zip
zalohaS08.02.2009.zip
zalohaS10.02.2009.zip
zalohaS11.02.2009.zip
zalohaS13.02.2009.zip
zalohaS14.02.2009.zip
zalohaS15.02.2009.zip
zalohaS16.02.2009.zip
zalohaS30.01.2009.zip
zalohaS31.01.2009.zip
zalohaW08.02.2009.zip
zalohaW10.02.2009.zip
zalohaW11.02.2009.zip
zalohaW13.02.2009.zip
zalohaW14.02.2009.zip
zalohaW15.02.2009.zip
zalohaW16.02.2009.zip
zalohaW30.01.2009.zip
zalohaW31.01.2009.zip
pre disk f je tam iba aktualna zaloha... hmm
nexapem ci to je...
batacik:
if not exist g: net use g: \\10.224.34.9\g
"C:\zaloha\7-Zip\7z.exe" a -tzip d:\zaloha\zalohaG%date%.zip g:\*
if not exist f: net use f: \\10.224.34.9\f
"C:\zaloha\7-Zip\7z.exe" a -tzip d:\zaloha\zalohaF%date%.zip f:\*
if not exist w: net use w: \\10.224.34.6\w
"C:\zaloha\7-Zip\7z.exe" a -tzip d:\zaloha\zalohaW%date%.zip w:\*
if not exist s: net use s: \\10.224.34.9\spin
"C:\zaloha\7-Zip\7z.exe" a -tzip d:\zaloha\zalohaS%date%.zip S:\*
Problem muze byt v tom, ze nejaky soubor je zamknuty a zaloha se nemuze vytvorit.
Neumi 7Zip pres nejaky parametr LOG?
mno log sa da vytvorit tak ako pisal oval nizsie, len neviem ci to pomoze. Lebo 7zip ziadny errorlevel nevrati nakolko on ten zip subor s aktualnym datumom vytvori ale "zmaze" sa stary subor alebo ho popr. prepise ale neviem preco.. vsak datum je stale ten isty ako pri ostatnych suboroch a spusta sa to az po polnoci takze nie je dovod preco by mal vytvorit subor so starym nazvom. Ale asi tam skusim pridat nieco ako
if exist d:\zaloha\zalohaF%date%.zip
"C:\zaloha\7-Zip\7z.exe" a -tzip d:\zaloha\zalohaF%date%new.zip f:\*
else
"C:\zaloha\7-Zip\7z.exe" a -tzip d:\zaloha\zalohaF%date%.zip f:\*
Help v 7-zip.chm obsahuje i hodnoty návratových kódů v případě problémů:
Exit Codes from 7-Zip
7-Zip returns the following exit codes:
Code Meaning
0 No error
1 Warning (Non fatal error(s)). For example, one or more files were locked by some other application, so they were not compressed.
2 Fatal error
7 Command line error
8 Not enough memory for operation
255 User stopped the process
Zkusil jsem na souborech které běžící procesy odmítají povolit číst a v logu je vše zaznamenáno, včetně návratového kódu 7z.exe errorlevel, který je v tomto případě 1!
Obsah logu:
Creating archive e:\zalohaFpo.zip
Compressing 1495.tmp
...
Compressing adresar\ticB24.tmp
WARNING: The process cannot access the file because it is being used by another process.
Compressing adresar\ticD2C.tmp
Compressing adresar\ticEB0.tmp
WARNING: The process cannot access the file because it is being used by another process.
Compressing adresar\ticECA.tmp
...
Compressing Temp.iso
Compressing ~DF4111.tmp
WARNING: The process cannot access the file because it is being used by another process.
Compressing ~DFE59E.tmp
WARNING: The system cannot find the file specified.
Compressing ~DFE5AD.tmp
WARNING: The system cannot find the file specified.
WARNINGS for files:
e:\temp\adresar\ticB24.tmp : The process cannot access the file because it is being used by another process.
e:\temp\adresar\ticEB0.tmp : The process cannot access the file because it is being used by another process.
e:\temp\~DF4111.tmp : The process cannot access the file because it is being used by another process.
e:\temp\~DFE59E.tmp : The system cannot find the file specified.
e:\temp\~DFE5AD.tmp : The system cannot find the file specified.
----------------
WARNING: Cannot open 5 files
hmm dakujem idem vyskusat
Nejjednodušší je zkusit něco v podobě od druhého řádku
if not exist f: net use f: \\10.224.34.9\f
if not exist f: echo F stale neni >>%TEMP%\7z.log
"C:\zaloha\7-Zip\7z.exe" a -tzip d:\zaloha\zalohaF%date%.zip f:\* >>%TEMP%\7z.log
echo %errorlevel% >>%TEMP%\7z.log
nebo se podívat do logů sheduleru.
nemas to nastavene ako incremental? len taky tip