<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Is it just &#12415;? &#187; Zip</title>
	<atom:link href="http://blog.himmelrath.net/tag/zip/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.himmelrath.net</link>
	<description>ungeordneter Unfug</description>
	<lastBuildDate>Sun, 25 Jul 2010 08:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Simple backups with windows 2</title>
		<link>http://blog.himmelrath.net/tec/prog/simple-backups-with-windows-2/</link>
		<comments>http://blog.himmelrath.net/tec/prog/simple-backups-with-windows-2/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 20:44:34 +0000</pubDate>
		<dc:creator>Jens</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Technik]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Batch]]></category>
		<category><![CDATA[Rar]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Zip]]></category>

		<guid isPermaLink="false">http://blog.himmelrath.net/?p=432</guid>
		<description><![CDATA[Update: I made additional changes to the script which are a real improvement for my daily use. The current version is "0.3d [2010-01-08]"

Last week I wrote about a simple way to zip all subfolders of a specific folder which I use for my simple archiving strategy at work. Today I <a href="http://blog.himmelrath.net/tec/prog/simple-backups-with-windows-2/">[...]</a>]]></description>
			<content:encoded><![CDATA[<p class="remark">Ich werde mal versuchen einige meiner Einträge auf Englisch zu verfassen &#8211; um in der Übung zu bleiben.</p>
<p><strong>Update:</strong> I made additional changes to the script which are a real improvement for my daily use. The current version is &#8220;0.3d [2010-01-08]&#8221;</p>
<p>Last week I wrote about a <a href="http://blog.himmelrath.net/tec/prog/simple-backups-with-windows-1/">simple way to zip all subfolders of a specific folder</a> which I use for my simple archiving strategy at work. Today I would like to show you a simple script I wrote which backups files listed in a configuration file using rar and puts them into a single archive named after the current date and time. I wrote it to be used as a scheduled task that runs every few hours on some windows machine that is always on.<sup>1</sup></p>
<p>I will not show the complete code here, since it&#8217;s about 150 lines. You can download the whole <a href="/wp-content/uploads/2009/12/2010-01-08-FileBackup.zip">script package as .zip-archive</a>.</p>
<p>The archive contains four files:</p>
<table border="0">
<tbody>
<tr>
<th>INFO-README.TXT</th>
<td>Some Information about the script</td>
</tr>
<tr>
<th>KPSBackupList.ini</th>
<td>The file containing the list of files to backup. Can be changed in the KPSFileBackup.bat</td>
</tr>
<tr>
<th>startHidden.vbs</th>
<td>Just a simple Script file to start the batch file without showing a console-window</td>
</tr>
<tr>
<th>FileBackupConfig.bat</th>
<td>The batch config file. It contains the config-section where you can change the settings as explained below</td>
</tr>
<tr>
<th>KPSFileBackup.bat</th>
<td>The actual batch file, you may run.</td>
</tr>
</tbody>
</table>
<p>The following settings are available:</p>
<table border="0">
<tbody>
<tr>
<th>backupFilelist</th>
<td>The file containing the list of all files that should be backed up</td>
</tr>
<tr>
<th>destinationDir</th>
<td>Destination directory where all backup files are stored</td>
</tr>
<tr>
<th>prefix</th>
<td>The prefix is put before the date in the name of the backup file</td>
</tr>
<tr>
<th>retryTime</th>
<td>Number of seconds to wait before retrying if one of the files was open and could therefore not be put into the archive. This is an approximate value since I hadd to use a workaround to put the script to sleep.</td>
</tr>
<tr>
<th>maxRetries</th>
<td>Number of times the script will retry if one of the files was open</td>
</tr>
<tr>
<th>backupsToKeep</th>
<td>The number of old backups to keep</td>
</tr>
<tr>
<th>rarPath</th>
<td>Path to the RAR<sup>2</sup> executable file</td>
</tr>
</tbody>
</table>
<p><sup>1</sup> The reason for using a batch script and a Windows machine is simple: They do not use linux here. Though I might get my own litte Debian VM in the future, for now Windows has to suffice.</p>
<p><sup>2</sup> The reason for using RAR is simple: It comes preinstalled on all machines here.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.himmelrath.net/tec/prog/simple-backups-with-windows-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple backups with windows 1</title>
		<link>http://blog.himmelrath.net/tec/prog/simple-backups-with-windows-1/</link>
		<comments>http://blog.himmelrath.net/tec/prog/simple-backups-with-windows-1/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 14:51:08 +0000</pubDate>
		<dc:creator>Jens</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Batch]]></category>
		<category><![CDATA[Rar]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Zip]]></category>

		<guid isPermaLink="false">http://blog.himmelrath.net/?p=355</guid>
		<description><![CDATA[At my current workplace, working with Linux (or anything other than windows) seems to be something no one would even bother to think about.  So I had to dig into the world of Windows Batch Scripting in order to create those little tools that make my life  just a bit easier when using <a href="http://blog.himmelrath.net/tec/prog/simple-backups-with-windows-1/">[...]</a>]]></description>
			<content:encoded><![CDATA[<p class="remark">Ich werde mal versuchen einige meiner Einträge auf Englisch zu verfassen &#8211; um in der Übung zu bleiben.</p>
<p>At my current workplace, working with Linux (or anything other than windows) seems to be something no one would even bother to think about.  So I had to dig into the world of Windows Batch Scripting in order to create those little tools that make my life  just a bit easier when using linux.</p>
<p>The first thing I had to do was creating a script that simply backups folders. I have a folder which contains other folders that should be archived &#8211; I usually zip (or 7zip) them and move them to the backup space later, which is a fairly easy task using a bash-script and nautilus actions.</p>
<p>Under windows it&#8217;s not that much harder to accomplish. (In the following example I used WinRAR to compress the files because that&#8217;s what we use at work.)</p>
<p>The first thing I needed was of course the batch-file that does the actual work. Here it is:</p>
<pre>
@echo off

rem ===================== Begin Configuration =====================
rem !!! Do not use quotes for the values of the following variables !!!

rem Path to the WinRAR executable file
set winrarPath=%PROGRAMFILES%\WinRAR\WinRAR.exe

rem ====================== End Configuration ======================

rem Please only edit after this line if you know exactly what you are doing.

set curVer=0.1 [2009-11-26]

rem ======================== Begin Script ========================

rem Tell the user which version of the tool they use
echo.
echo                     Mi ArchiveSubfolders version %curVer%
echo.
echo.

if not exist "%winrarPath%" (
    echo Cannot find WinRAR exe file: %winrarPath%
    goto eof
)

set dir=%*
if not exist "%dir%" (
    echo The directory "%dir%" cannot be found
    goto eof
)

set dateString=%DATE:~-4,4%-%DATE:~-7,2%-%DATE:~0,2%_%TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2%

cd "%dir%"
for /D %%a in (*) do (
    rem Creating the archive
    echo Archiving "%%~na"...
    "%winrarPath%" M -afzip -ibck -inul -m5 "%dateString%-%%~na.zip" "%%a"
)

echo.
echo Archiving done

:eof
</pre>
<p>Now that is a nice, simple script, but what should I do with it? I wanted it to be useable directly in the explorer context-menu, so I made a small registry-entry. This is the exported .reg-file:</p>
<pre>
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Folder\shell\archiveSubfolders]
@="Mi: Archive Subfolders (ZIP)"

[HKEY_CLASSES_ROOT\Folder\shell\archiveSubfolders\Command]
@="cmd /c \"\"%%ProgramFiles%%\\MiTools\\archiveSubfolders\\archiveSubfolders.bat\"\" %1"
</pre>
<p>Now I wanted a simple installation-script, for really lazy people like me:</p>
<pre>
@echo off

set installDir=%PROGRAMFILES%\MiTools\archiveSubfolders

if not exist "%installDir%" (
    mkdir "%installDir%"
)

copy archiveSubfolders.bat "%installDir%"
copy "ArchiveSubfolders Context Menu Entry.reg" "%installDir%"

regedit /S "ArchiveSubfolders Context Menu Entry.reg"

echo Installation complete.

:eof
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.himmelrath.net/tec/prog/simple-backups-with-windows-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
