Advertisement
IsaacSin

backup.bat (Cataclysm)

Mar 1st, 2013
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. @echo off
  2. ::This name doesn't actually matter, it's just to name the backup folder.
  3. set charToPreserve=INSERTNAMEHERE
  4. set done=0
  5.  
  6. start cataclysm.exe
  7.  
  8. :backup
  9. set Year=
  10. for /f "skip=2" %%x in ('wmic Path Win32_LocalTime get Year^,Month^,Day^,Hour^,Minute^,Second /Format:List') do (
  11. if not defined Year set %%x
  12. )
  13. if %Month% LSS 10 set Month=0%Month%
  14. if %Day% LSS 10 set Day=0%Day%
  15. if %Minute% LSS 10 set Minute=0%Minute%
  16. if %Hour% LSS 10 set Hour=0%Hour%
  17. set Timestamp=%Year%.%Month%.%Day% %Hour%%Minute%
  18.  
  19. xcopy /s /i /y save "backups\%charToPreserve% %Timestamp%" >NUL
  20.  
  21. if %done%==0 goto sleep
  22. exit
  23.  
  24. :sleep
  25. set sleep=0
  26. :sleeploop
  27. ::Check if Cataclysm is running. If it is, loop. If not, we do a final backup and we're done.
  28. tasklist /FI "IMAGENAME eq cataclysm.exe" 2>NUL | find /I /N "cataclysm.exe">NUL
  29. if not "%ERRORLEVEL%"=="0" set done=1 & goto backup
  30. ::Ping nothing and output nothing for five seconds. Equivalent to "sleep" or "wait".
  31. ping -n 6 127.0.0.1 >NUL
  32. set /A sleep+=1
  33. ::Sleep 60 times (five minutes) then backup.
  34. if %sleep% lss 60 goto sleeploop
  35. goto backup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement