A
A
Anton2015-04-28 14:50:17
Data archiving
Anton, 2015-04-28 14:50:17

How to take into account the reset of the system time?

Good day.
There is a backup script:

@Echo Off

echo %date% %time% ***Start***

SetLocal EnableDelayedExpansion

Set $SRC=list_add.txt

Set $EXC=list_excl.txt

Set $DIR=C:\backtest

Set $PSW=1

Set $COMPR=5

Set $COPIES=7

C:\"Program Files"\7-Zip\7z.exe a -t7z "%$DIR%\file%DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%_%TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2%.7z" @%$SRC% -scsWIN -p%$PSW% -mx=%$COMPR% -ssw [email protected]%$EXC% >> log_7z.log

For /F "Delims=" %%i In ('DIR /B/O:-N %$DIR%\file????-??-??_??-??-??.7z') Do (

Set /A $COPIES-=1

If !$COPIES! LSS 0 DEL "%$DIR%\%%i"

)

echo %date% %time% ***End***

If the system date jumps forward - it overwrites old files, everything works. But if the date is rolled back, the script stops deleting files. And you need to write anyway, despite the date.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question