Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- REM Get system date & time no matter your system local
- REM ALL CREDITS TO Derty2 https://stackoverflow.com/a/16777802/2792969
- REM.
- SETLOCAL
- COLOR 0A
- TITLE Generating wallet backups for C: (including backups and config files)...
- :: --- CHANGE THE COMPUTER DATE FORMAT TEMPORARILY TO MY PREFERENCE "yyyy-MM-dd",
- REG COPY "HKCU\Control Panel\International" "HKCU\Control Panel\International-Temp" /f 2>nul >nul
- REG ADD "HKCU\Control Panel\International" /v sShortDate /d "yyyy.MM.dd" /f 2>nul >nul
- SET MYDATE=%date%
- :: --- REVERT COMPUTER DATE BACK TO SYSTEM PREFERENCE
- REG COPY "HKCU\Control Panel\International-Temp" "HKCU\Control Panel\International" /f 2>nul >nul
- REG DELETE "HKCU\Control Panel\International-Temp" /f 2>nul >nul
- :: --- SPLIT THE TIME DIGITS TO THREE BLOCKS [H] [MM] [SS.SS]
- FOR /F "tokens=1-3 delims=:" %%A IN ('echo %time%') DO SET HOUR=%%A& SET MINUTES=%%B& SET SECONDS=%%C
- :: --- YOUR CHOICE - FOR 4 DIGIT SECONDS - REMOVES THE DOT FROM THE SECONDS BLOCK [SS.SS]
- :: SET SECONDS=%SECONDS:.=%
- :: --- YOUR CHOICE - FOR 2 DIGIT SECONDS - GETS THE FIRST TWO DIGITS FROM THE SECONDS BLOCK [SS.SS]
- SET SECONDS=%SECONDS:~0,2%
- :: --- GET THE "AM PM" STRING TO CHECK THE HOUR BLOCK
- FOR /F "tokens=1,2 delims= " %%A IN ('time /t') DO SET AM_PM=%%B
- :: --- CONVERT THE HOUR BLOCK [H] TO "24 HOUR" FORMAT [HH]
- IF %AM_PM%==PM (
- IF %HOUR%==01 (SET HOUR=13)
- IF %HOUR%==02 (SET HOUR=14)
- IF %HOUR%==03 (SET HOUR=15)
- IF %HOUR%==04 (SET HOUR=16)
- IF %HOUR%==05 (SET HOUR=17)
- IF %HOUR%==06 (SET HOUR=18)
- IF %HOUR%==07 (SET HOUR=19)
- IF %HOUR%==08 (SET HOUR=20)
- IF %HOUR%==09 (SET HOUR=21)
- IF %HOUR%==10 (SET HOUR=22)
- IF %HOUR%==11 (SET HOUR=23)
- ) ELSE (
- IF %HOUR%==0 (SET HOUR=00)
- IF %HOUR%==12 (SET HOUR=00)
- IF %HOUR%==1 (SET HOUR=01)
- IF %HOUR%==2 (SET HOUR=02)
- IF %HOUR%==3 (SET HOUR=03)
- IF %HOUR%==4 (SET HOUR=04)
- IF %HOUR%==5 (SET HOUR=05)
- IF %HOUR%==6 (SET HOUR=06)
- IF %HOUR%==7 (SET HOUR=07)
- IF %HOUR%==8 (SET HOUR=08)
- IF %HOUR%==9 (SET HOUR=09)
- )
- :: --- GENERATE OUR WANTED TIMESTAMP
- :: --- EXAMPLE: SET TIMESTAMP=%MYDATE%__%HOUR%_%MINUTES%_%SECONDS%
- SET TIMESTAMP=%HOUR%.%MINUTES%_%SECONDS%
- REM FAILS SET TIMESTAMP=%HOUR%h%MINUTES%_%SECONDS%
- :: --- WAIT - VIEW THE RESULT IN THE CONSOLE SCREEN
- ECHO Your archive's timestamp ID will be: %TIMESTAMP% (hh.MM_ss)
- echo.
- echo.
- REM pause
- :: --- NEXT STEP - WINRAR IT ALL!
- c:
- cd "C:\Program Files\WinRAR\"
- set base_archive=E:\= RAIN= CRYPTO\== Wallet Backups\= Winrar Incremental Backups\Wallets C-Disk .rar
- set base_archive_list=E:\= RAIN= CRYPTO\== Wallet Backups\= Winrar Incremental Backups\Wallets C-Disk *.rar
- set archive_folder=E:\= RAIN= CRYPTO\== Wallet Backups\= Winrar Incremental Backups
- set files_to_add="C:\*wallet*.dat" "C:\*wallet*.bak" "C:\*wallet*.old" "C:\*.conf"
- set exclude_folders=-x*\Windows -x*\Windows\* -x*\Microsoft -x*\Microsoft\*
- REM -k switch prevents any further archive modifications by WinRAR
- REM -oh -ol switches only stores links, not their destination
- set overlapping_parameters=-ac -dh -ep2 -htb -k -m5 -ma5 -md1g -oh -ol -os -qo+ -se -t -ts -r
- set ID=YYYY.MM.DD__%TIMESTAMP%
- echo Winrar Incremental Wallets Backup C: (%DATE% at %TIME%) > C:\Temp\winrar.message.C.txt
- set comment=C:\Temp\winrar.message.C.txt
- echo Output folder: %archive_folder%
- echo Main archive: %base_archive%
- echo Looking on C: for %file_list% (including subfolders)
- echo.
- echo.
- REM pause
- :: --- CREATING DIFFERENTIAL RAR BACKUP OR MAIN ARCHIVE
- REM IF NOT EXIST C:\Temp mkdir C:\Temp
- set cleanup=del /F /Q C:\Temp\winrar.message.C.txt
- IF EXIST "%base_archive_list%" GOTO create_incrementals ELSE GOTO create_main_archive
- :create_main_archive
- echo %base_archive_list% for drive C: not found! Creating it next... Hold on!
- echo.
- echo.
- rar a -rr100%% %overlapping_parameters% %exclude_folders% -z%comment% -ag%ID%___FULL "%base_archive%" %files_to_add%
- %cleanup%
- REM pause
- goto :eof
- :create_incrementals
- echo %base_archive_list% for drive C: has been found!
- echo Updating any changed or new files to it (even when in use)... Hold on!
- echo.
- echo.
- rar a -rr100%% -ao -u %overlapping_parameters% %exclude_folders% -z%comment% -ag%ID%___incr "%base_archive%" %files_to_add%
- %cleanup%
- REM pause
- goto :eof
- REM https://x443.wordpress.com/2012/07/11/winrar-incremental-differential-backup/
- REM Full backup example: winrar.exe a -se -rr3% -ag+YYYYMMDD_full_ -k -m5 -ms -os -r -ep1 -ac e:\mydoc.rar c:\docs\*
- REM Incremental backup example: winrar.exe a -se -rr3% -ag+YYYYMMDD_incr_ -k -m4 -ms -os -r -ep1 -ac -ao e:\mydoc.rar c:\docs\*
- REM Differential backup example: winrar.exe a -se -rr3% -ag+YYYYMMDD_diff_ -k -m4 -ms -os -r -ep1 -ao e:\mydoc.rar c:\docs\*
- REM Have you read in help of WinRAR about the switch -ac which is designed for backup purposes and the switch -ao?
- REM The first command line runs WinRAR to archive all files with compression into the full archive file with clearing the archive
- REM file attribute from all files put into the archive file. The second command line compresses into the incremental archive file
- REM only files with archive attribute set because of -ao. All other files with no archive attribute are ignored on this second file
- REM archiving.
- REM.
- REM -ag+YYYYMMDD_ puts YYYYMMDD_ in FRONT of the filename. -agYYYYMMDD_ puts YYYYMMDD_ at the END of the filename.
- REM.
- REM -rr100% (recovery record) might be overkill ;)
- :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement