Reputation: 4306
i want to dump the data excluding contenttype. I am gerring error so that i wnt apply try catch to code. So that i can find out what error i am facing.
set /p pathName=Enter The path where you want to take backup:%=%
@echo %pathName%
set d=%date:~-4,4%_%date:~-7,2%_%date:~0,2%
set d=%d: =_%
set t=%time:~0,2%_%time:~3,2%_%time:~6,2%
set t=%t: =0%
md %pathName%\media
try{
python dtz/manage.py dumpdata -e contenttype>> %pathName%/Backup_on_%d%_%t%.json
}
catch
{
python dtz/manage.py dumpdata>> %pathName%/Backup_on_%d%_%t%.json
}
pause
xcopy dtz\templates\media %pathName%\media /s
Error i am getting CommandError: Unknown app in excludes: contenttype
Please help me out.
Upvotes: 1
Views: 4912
Reputation: 2815
There are no try-catch
blocks in batch scripts. You need to use the errorlevel
returned by a command to check whether it executed successfully or failed. Generally errorlevel 0
indicates that the command executed successfully, but the errorlevel can also depend on the command/program being executed.
Details about ERRORLEVEL.
ERRORLEVEL can be used as follows:
IF %ERRORLEVEL% NEQ 0 (do something)
Upvotes: 2