@ECHO OFF CLS :: Ziparcy.cmd :: Author :: Micah Wittman :: :: :: License :: SEE license.txt :: :: Version :: 0.8 :: :: Release :: 2008-07-17 :: :: Application Description :: Scheduled Primary / Incremental, Encrypted-Archive Backups via WINNT shell script: :: 1) Update primary 7zip backup encrypted archive with any changed files (backup.7z). :: 2) Copy primary archive to a new, timestamped, incremental archive file (backup_12.31.00.7z) :: and update with any changed files. :: :: Dependencies :: 7zip: http://www.7-zip.org/ :: Used for archive compression/encryption :: :: Wget: http://www.gnu.org/software/wget/ :: Used for command-line downloading of the encryption key. As an alternative, you can :: forgo using wget and just hard-code the encryption key directly in this script. :: :: Configuration Details :: APPDIR Application Directory (location of Ziparcy.cmd script) :: FILESTOBACKUPDIR Files to Backup directory (includes all subdirectories/files) :: SZDIR 7zip Application directory :: TEMPDIR Temporary directory (where 7zip builds temp file during archiving process) :: BACKUPTODIR Directory to store encrypted archive backups :: LOGDIR Directory in which log files are kept :: ENCURL Encryption Key URL from which encryption key is downloaded :: ENCFILE Encryption Key file local path where downloaded key is created, read, and deleted ::CONFIGURATION BEGIN ::::::::::::::::::::::::::::::::::::: ::Directory Variables SET APPDIR=C:\Apps\Ziparcy SET FILESTOBACKUPDIR=C:\Data Dumps\Foo Files SET SZDIR=C:\Program Files\7-Zip SET TEMPDIR=%TEMP% SET BACKUPTODIR=%CD% SET LOGDIR=%CD% SET ENCDIR=%CD% ::Encryption Key Variables SET ENCURL=https://your-domain.com/ziparcy_securitythruobscurity_KL2asfkmak25ag2ht450/encryptkey.php SET ENCFILE=encryptkey.php ::CONFIGURATION END ::::::::::::::::::::::::::::::::::::: ECHO ZIP and ARCHIVE Processing ... ::Date Variables - replace characters that are not legal as part of filesystem file names (to produce name like "backup_04.15.08.7z") SET DT=%date% SET DT=%DT:/=.% SET DT=%DT:-=.% SET FILESET=%FILESTOBACKUPDIR% SET FILESET=%FILESET: =_% SET FILESET=%FILESET:\=.% SET FILESET=%FILESET::=% ::Change directory to location where this script, Ziparcy.cmd CD %APPDIR% ::Get encryption key from web server so key has no permanent storage on the local disk wget --no-check-certificate %ENCURL% ::Ping to buy some time so wget can finish downloading the encryption key from the web server PING google.com ::Password Variable set from encryption key download SET /p PASSWORD= <"%ENCFILE%" ::Delete encryption key download DEL "%ENCFILE%" ::Run Backup:: ECHO --------------------------------------------------- >> "%LOGDIR%\backup.log" ECHO begin ziparcy %date% %time% >> "%LOGDIR%\backup.log" ::Create/Update "backup.7z" "%SZDIR%\7z" u -p%PASSWORD% -t7z -w%TEMP% -ms=off -mx=7 "%BACKUPTODIR%\backup.7z" "%FILESTOBACKUPDIR%\" >> "%LOGDIR%\backup.log" ::Duplicate "backup.7z" (from step above) to new timestamped copy ("bacukup_12.31.00.7z") COPY "%BACKUPTODIR%\backup.7z" "%BACKUPTODIR%\backup_%DT%.7z" ECHO ZIP and ARCHIVE Processing Continuing ... ::Append timestamped Log "%SZDIR%\7z" u -p%PASSWORD% -t7z -w%TEMP% -ms=off -mx=7 "%BACKUPTODIR%\backup_%DT%.7z" "%FILESTOBACKUPDIR%\" >> "%LOGDIR%\backup_%DT%.log" ECHO end ziparcy %date% %time% >> "%LOGDIR%\backup.log" ::EOF