nav-left cat-right
cat-right
Matthias Pospiech > Programming > batch > batch script for automatic backup using winrar

batch script for automatic backup using winrar

For a regular full backup of all my important data I am using a bash script on Linux. This is now an example to achieve the same under Windows 7 using batch scripting and winrar as the compressor. Zip files can not be used since this is limited in total number of files which I typically overcome.

@ECHO OFF
cls
::-------------------------------------------------------------------------------------
SET PACKER="c:\Program Files\WinRAR\RAR.exe"

:: %APPDATA% = "C:\Users\Matthias\AppData\Roaming"
:: %USERNAME% = "Matthias"
:: %HOMEPATH% = "Users\Matthias"
:: %HOMEDRIVE% = "C:\"
SET DIRUSER="%HOMEDRIVE%%HOMEPATH%"
SET DIRUSERDOC="%DIRUSER%\Documents"
::SET SAVEDIR="c:\temp\%DATE%\"
SET SAVEDIR="Y:\%DATE%"
call:funcCreateDir %SAVEDIR%

 
::--------------------------------------------------------
:: --- MAIN ----------------------------------------------
::--------------------------------------------------------

::Backup home:AppData:Thunderbird
	SET TARGET="%SAVEDIR%\Win7.AppData.Thunderbird.rar"
	SET FILES="%APPDATA%\Thunderbird\*"
	::call:funcBackup %TARGET% %FILES%

::Backup home:User (without AppData, Documents and other real data)
	SET TARGET="%SAVEDIR%\Win7.User.Matthias.rar"
	SET FILES="%DIRUSER%\*"
	SET EXLUCDE="-x%DIRUSER%\AppData -x%DIRUSER%\Downloads -x%DIRUSER%\Pictures -x%DIRUSER%\Documents -x%DIRUSER%\Music -x%DIRUSER%\Videos " 
	::call:funcBackup %TARGET% %FILES% %EXLUCDE%

::Backup home:User:Documents
	SET TARGET="%SAVEDIR%\Win7.User.Matthias.Documents.rar"
	SET FILES="%DIRUSER%\Documents"		
	SET EXLUCDE="-x%DIRUSER%\Documents\SVN" 
	call:funcBackup %TARGET% %FILES% %EXLUCDE%
	
::Backup system:Fonts	
	SET TARGET="%SAVEDIR%\Win7.Fonts.rar"
	SET FILES="%WINDIR%\Fonts\*"
	::call:funcBackup %TARGET% %FILES%
	
::Backup latex:texmf
	SET TARGET="%SAVEDIR%\Win7.localtexmf.rar"
	SET FILES="c:\localtexmf\*"
	::call:funcBackup %TARGET% %FILES%

::Backup home:AppData (without Thunderbird)
	SET TARGET="%SAVEDIR%\Win7.AppData.rar"
	SET FILES="%DIRUSER%\AppData\*"
	SET EXLUCDE="-x%APPDATA%\Thunderbird"
	::call:funcBackup %TARGET% %FILES% %EXLUCDE%
 
echo.&pause&goto:eof

::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------
 
:funcBackup
	SET TARGET=%~1
	SET FILES=%~2
	SET EXCLUDE=%~3
	echo."%PACKER% a -r %EXCLUDE% %TARGET% %FILES%"
	call %PACKER% a -r %EXCLUDE% %TARGET% %FILES%
goto:eof
 
:funcCreateDir
	echo "creating %~1"
	IF NOT EXIST "%~1" md "%~1"
goto:eof

Keine Antworten : “batch script for automatic backup using winrar”

Trackbacks/Pingbacks

  1. Automatisch Ordner packen - ModControl.Com - GermanysNr1MultiConsoleSceneSource - [...] me google that for you batch script for automatic backup using winrar- Matthias Pospiech Tutorial - Using WinRAR command-line…

Einen Kommentar schreiben

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

*

This blog is kept spam free by WP-SpamFree.