2

I'm trying to make backup script, which archives my files, and then test if the archive is ok. That was the easy part. It looks like this:

"C:\Program Files (x86)\WinRAR\rar.exe" a -ep1 -r "D:\test_%date:~-4,4%%date:~-7,2%%date:~-10,2%_.rar"  "D:\mybackup_18-05-2016.bak" -t

So now I have to use the rar test result, and if it says ALL OK to delete the original *.bak files. Can you help the newbie please :)

npocmaka
  • 51,748
  • 17
  • 123
  • 166

1 Answers1

1
"C:\Program Files (x86)\WinRAR\rar.exe" a -ep1 -r "D:\test_%date:~-4,4%%date:~-7,2%%date:~-10,2%_.rar"  "D:\mybackup_18-05-2016.bak" -t | find / "ALL OK" >nul 2>nul && (
   echo ok.
   del /q /f "D:\mybackup_18-05-2016.bak" 
   color
)||(
   echo not ok.
)

?

Though it is not good idea to use %date% variable as it is not time settings independent and on different machine it can has a different format.

npocmaka
  • 51,748
  • 17
  • 123
  • 166
  • Thanks a lot - it worked for me. About the date - I need it, because there will be daily and weekly backups, so it's easier to find what I need – Недорасъл Жираф May 18 '16 at 15:10
  • @НедорасълЖираф - you can check [this](http://stackoverflow.com/a/19799236/388389) if you intend to run this on other machines. – npocmaka May 18 '16 at 15:15