<?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>Logaan's Site &#187; Backups</title>
	<atom:link href="http://www.logaans-site.co.uk/tag/backups/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.logaans-site.co.uk</link>
	<description>In my own little world, world...world</description>
	<lastBuildDate>Thu, 29 Dec 2011 10:00:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Simpler version of the 7-Zip backup</title>
		<link>http://www.logaans-site.co.uk/2009/10/17/simpler-version-of-the-7-zip-backup/</link>
		<comments>http://www.logaans-site.co.uk/2009/10/17/simpler-version-of-the-7-zip-backup/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 00:16:38 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[Batch]]></category>
		<category><![CDATA[Backups]]></category>
		<category><![CDATA[batch scripting]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=494</guid>
		<description><![CDATA[I have tested the 7-Zip backup I had constructured that I posted about a while back and I have come to realise that it is a tad bit too complicated. I even went through the process of creating a proxy application to try and get it to be a bit more cleverer but in the [...]]]></description>
			<content:encoded><![CDATA[<p>I have tested the 7-Zip backup I had constructured that I posted about a while back and I have come to realise that it is a tad bit too complicated. I even went through the process of creating a proxy application to try and get it to be a bit more cleverer but in the end I simplified it down to just 4 parts; the logic, settings and file lists.</p>
<p><strong>Backup.cmd</strong></p>
<pre class="brush: plain; auto-links: false; title: ; notranslate">
@ECHO OFF

ECHO 7-Zip backup script
ECHO Written by Alex Boyne-Aitken
ECHO Last update: 07/11/2009
ECHO.

ECHO TRACE: Parse arguments: '%~f1'
IF EXIST %~f1 GOTO labelBegin

ECHO.
ECHO ERROR: Settings file not found!
GOTO labelWaitEnd

:labelBegin

ECHO.
ECHO TRACE: Reading settings
FOR /F &quot;eol=# tokens=1,2 delims==&quot; %%i IN (%~f1) DO (
SET %%i=%%j
ECHO TRACE: %%i = '%%j'
)

SET varTimeStamp=%DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%-%TIME:~0,2%-%TIME:~3,2%
SET varTargetBackupSet=%varBackupPath%\%varTimeStamp%-backup.zip

ECHO.
ECHO TRACE: Backup set: '%varTargetBackupSet%'
ECHO TRACE: Command line: '&quot;%varPathToSevenZip%\7z&quot; a -t%varArchiveType% &quot;%varTargetBackupSet%&quot; @&quot;%varInclusionsFile%&quot; -xr@&quot;%varExclusionsFile%&quot;'

ECHO.
ECHO TRACE: Executing backup
&quot;%varPathToSevenZip%\7z&quot; a -t%varArchiveType% &quot;%varTargetBackupSet%&quot; @&quot;%varInclusionsFile%&quot; -xr@&quot;%varExclusionsFile%&quot;

IF /I NOT &quot;%varWaitAtEnd%&quot; == &quot;true&quot; GOTO labelEnd

:labelWaitEnd
PAUSE
:labelEnd
</pre>
<p><strong>Settings.txt</strong></p>
<pre class="brush: plain; auto-links: false; title: ; notranslate">
# The path to the where the 7z.exe executable is
varPathToSevenZip=C:\Program Files\7-Zip

# The path where to store the backup sets
varBackupPath=D:\Backups

# The file path to the inclusions file
varInclusionsFile=D:\Logaan\Documents\Tools\7ZipBackup\Settings\Inclusions.txt

# The file path to the exclusions file
varExclusionsFile=D:\Logaan\Documents\Tools\7ZipBackup\Settings\Exclusions.txt

# Whether to wait at the end of the backup
varWaitAtEnd=true

# Type of backup archive to create
varArchiveType=zip
</pre>
<p><strong>Exclusions.txt</strong></p>
<pre class="brush: plain; auto-links: false; title: ; notranslate">
*.svn
</pre>
<p><strong>Inclusions.txt</strong></p>
<pre class="brush: plain; auto-links: false; title: ; notranslate">
D:\Logaan\Documents
D:\Logaan\Favorites
C:\Users\Logaan\Desktop
D:\Logaan\Saved Games
</pre>
<p><strong>How to use it</strong></p>
<p>Place the batch file and settings files in a folder somewhere.</p>
<p>Update the setttings file with the correct paths.</p>
<p>Pass the path to the settings file to the backup batch file.</p>
<pre class="brush: plain; auto-links: false; title: ; notranslate">
C:&gt; backup D:\Logaan\Documents\Backup\settings.txt
</pre>
<p>Or create a scheduled task.</p>
<p><a href="http://www.logaans-site.co.uk/wp-content/uploads/2009/10/EditAction.png"><img class="aligncenter size-full wp-image-519" title="Edit Action" src="http://www.logaans-site.co.uk/wp-content/uploads/2009/10/EditAction.png" alt="Edit Action" width="468" height="504" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2009/10/17/simpler-version-of-the-7-zip-backup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using 7-zip and batch files to perform backups automatically</title>
		<link>http://www.logaans-site.co.uk/2009/04/06/using-7-zip-and-batch-files-to-perform-backups-automatically/</link>
		<comments>http://www.logaans-site.co.uk/2009/04/06/using-7-zip-and-batch-files-to-perform-backups-automatically/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 20:56:49 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[Batch]]></category>
		<category><![CDATA[Logaan's Toolkit]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Backups]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=393</guid>
		<description><![CDATA[UPDATE: I have recently overhauled this and created a simpler script in this post: Simpler Version of the 7-zip backup First, a little history: Since the days when I started using XP I had gotten used to the control that NT Backup provided to allow me to backup my files. About a year ago I [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: </strong>I have recently overhauled this and created a simpler script in this post: <a href='http://www.logaans-site.co.uk/2009/10/17/simpler-version-of-the-7-zip-backup/' >Simpler Version of the 7-zip backup</a></p>
<p>First, a little history:</p>
<p>Since the days when I started using XP I had gotten used to the control that NT Backup provided to allow me to backup my files.</p>
<p>About a year ago I moved to Vista and was unhappy with the &#8220;All or nothing&#8221; approach that the bundled backup software provided. I was also using OneCare at the time and it followed a similar policy.</p>
<p>Since moving to BitDefender I was much happier with the backup software it provided yet the fact that I was not using a well known backup format rubbed me.</p>
<p>So, using this article: <a title="http://www.wilshireone.com/article/115/easy-backups-with-7-zip" href="http://www.wilshireone.com/article/115/easy-backups-with-7-zip" target="_blank">http://www.wilshireone.com/article/115/easy-backups-with-7-zip</a> as a guide, I engineered my own backup mechnism using 7-zip.</p>
<p>Now heres the fun. My backup schedule consists of a weekly incremental backup and one monthly full backup. My files are not so important that I need frequent backups, this schedule suits me down to the ground.</p>
<p>My solution consists of 7 parts:</p>
<ul>
<li><strong>Backup.cmd</strong>, this is the main script that executes the command</li>
<li><strong>Backupset.txt</strong>, a list of files and folders that I wish to backup</li>
<li><strong>CurrentSet.txt</strong>, a path to the current backup file. Used by incremental backups to update</li>
<li><strong>FullBackup.cmd</strong>, the script to run a full backup</li>
<li><strong>FullBackupSettings.ini</strong>, the settings used by a full backup</li>
<li><strong>IncrementalBackup.cmd</strong>, the script to run an incremental backup</li>
<li><strong>IncrementalBackupSettings.ini</strong>, the settings used by the incremental backup</li>
</ul>
<p>Now you could remove the separate scripts for the full and incremental backup, the reason I created separate scripts was that I don&#8217;t have to change the arguments in the task scheduler. Instead it is all controlled through those scripts.</p>
<p><strong>Backup.cmd</strong></p>
<pre class="brush: plain; auto-links: false; title: ; notranslate">
@echo off

echo TRACE: Start

IF EXIST %1 GOTO Begin

echo Settings file does not exist
GOTO End

:Begin

echo TRACE: Read settings
for /f &quot;eol=# tokens=1,2 delims==&quot; %%i in (%1) do SET %%i=%%j

IF &quot;%varBackupType%&quot;==&quot;full&quot; GOTO CreateNewSet

echo TRACE: Load existing set
for /F %%i in (CurrentSet.txt) do set varTargetBackupSet=%%i

IF EXIST &quot;%varTargetBackupSet%&quot; GOTO Execute

echo Backup set does not exist!
GOTO End

:CreateNewSet
echo TRACE: Create new set

set varTargetBackupSet=%varBackupLocation%\%DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%-%TIME:~0,2%-%TIME:~3,2%-backup.%varFormat%
echo %varTargetBackupSet% &gt; CurrentSet.txt

:Execute
echo TRACE: Execute backup
&quot;%var7zipPath%\7z&quot; %varMode% -t%varFormat% &quot;%varTargetBackupSet%&quot; @&quot;%varFileList%&quot;

:End
echo TRACE: Finished
pause
</pre>
<p>The backup script loads the settings passed as argument 1, does some checking, then calls 7-zip to begin backing up. The settings files define how the files are added and where to etc.</p>
<p><strong>BackupSet.txt</strong></p>
<pre class="brush: plain; auto-links: false; title: ; notranslate">
D:\Guild Wars\Screens
D:\Logaan\Documents
D:\Logaan\Favorites
C:\Users\Logaan\Desktop
D:\Logaan\Saved Games
C:\Users\Logaan\AppData\Local\2DBoy
C:\Users\Logaan\AppData\Local\Ascaron Entertainment
C:\Users\Logaan\AppData\Local\id Software
C:\Users\Logaan\AppData\Local\Ironclad Games
C:\Users\Logaan\AppData\Local\Rockstar Games
C:\Users\Logaan\AppData\Roaming\EditPlus 3
C:\Users\Logaan\AppData\Roaming\FileZilla
C:\Users\Logaan\AppData\Roaming\Free Download Manager
C:\Users\Logaan\AppData\Roaming\Xfire
</pre>
<p>This is the list file passed to 7-zip. The only downside is that you cannot list the same folder or file name twice in this file. The work around would be to invoke multiple backup scripts and then add the duplicate folders and nested zips.</p>
<p><strong>CurrentSet.txt</strong></p>
<pre class="brush: plain; auto-links: false; title: ; notranslate">D:\2009-04-05-17-16-backup.zip</pre>
<p>This contains the backup file created in the last full backup. Incremental backups then read it in and use it to update files.</p>
<p><strong>FullBackup.cmd</strong></p>
<pre class="brush: plain; auto-links: false; title: ; notranslate">
@echo off
Backup D:\Logaan\Documents\Tools\7ZipBackup\FullBackupSettings.ini
</pre>
<p>Simples, it just calls the main backup script with the correct settings.</p>
<p><strong>FullBackupSettings.ini</strong></p>
<pre class="brush: plain; auto-links: false; title: ; notranslate"># File path to the 7-zip executables
var7zipPath=C:\Program Files\7-Zip

# Backup format
varFormat=zip

# Target location for the backup
varBackupLocation=D:

# List file
varFileList=D:\Logaan\Documents\Tools\7ZipBackup\BackupSet.txt

# Mode
varMode=a

# Type
varBackupType=full</pre>
<p>The settings file is read in and used in the main backup script. Note the mode and backup type, this is what separates the two types of backup.</p>
<p><strong>IncrementalBackup.cmd</strong></p>
<pre class="brush: plain; auto-links: false; title: ; notranslate">
@echo off
Backup D:\Logaan\Documents\Tools\7ZipBackup\IncrementalBackupSettings.ini
</pre>
<p>Similar to the full version, except its providing the increment backup settings</p>
<p><strong>IncrementalBackupSettings.ini</strong></p>
<pre class="brush: plain; auto-links: false; title: ; notranslate">
# File path to the 7-zip executables
var7zipPath=C:\Program Files\7-Zip

# Backup format
varFormat=zip

# Target location for the backup
varBackupLocation=D:

# List file
varFileList=D:\Logaan\Documents\Tools\7ZipBackup\BackupSet.txt

# Mode
varMode=u

# Type
varBackupType=incremental
</pre>
<p>Similar to the full settings, but with the zip mode set to update and its backup type defined as incremental.</p>
<p>Once that has all been put in place, all I do is create two tasks in the windows task scheduler.</p>
<p>You could go one step further and have the script copy the backups to another disk, I just do this myself when I feel like.</p>
<p><strong>Update</strong></p>
<p>After a little testing I found a flaw in the technique that I was using. Essentially what is happening is that new files are being added to the old archive and any deleted files were being left. I want to keep any files that I deleted but I do not want them muddying up the actual latest image.</p>
<p>Instead, what I did was use the <em>-u</em> switch to stop updates to the base archive being made and adding new files to a new archive, which makes it incremental in its true sense.</p>
<p><strong>Backup.cmd</strong></p>
<pre class="brush: plain; auto-links: false; title: ; notranslate">
@echo off

echo TRACE: Start

IF EXIST %1 GOTO Begin

echo Settings file does not exist
GOTO End

:Begin

echo TRACE: Read settings
for /f &quot;eol=# tokens=1,2 delims==&quot; %%i in (%1) do SET %%i=%%j

set varNewBackupSet=%varBackupLocation%\%DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%-%TIME:~0,2%-%TIME:~3,2%-backup.%varFormat%

IF &quot;%varBackupType%&quot;==&quot;full&quot; GOTO CreateNewSet

echo TRACE: Load existing set
for /F %%i in (CurrentSet.txt) do set varOldBackupSet=%%i

IF EXIST &quot;%varOldBackupSet%&quot; GOTO ExecuteIncremental

echo Backup set does not exist!
GOTO End

:CreateNewSet
echo TRACE: Create new set
echo %varNewBackupSet% &gt; CurrentSet.txt

:ExecuteFull
echo TRACE: Execute Full backup
&quot;%var7zipPath%\7z&quot; a -t%varFormat% &quot;%varNewBackupSet%&quot; @&quot;%varFileList%&quot;
GOTO End

:ExecuteIncremental
echo TRACE: Execute Incremental backup
&quot;%var7zipPath%\7z&quot; u -u- -u!&quot;%varNewBackupSet%&quot; -t%varFormat% &quot;%varOldBackupSet%&quot; @&quot;%varFileList%&quot;

:End
echo TRACE: Finished
pause
</pre>
<p>In fact, I have gone one step further and I have built a command line tool that wraps 7-zip and provides a nicer mechanism for configuring the backups. It then executes 7-zip. Once I have tested it a little I will post the source code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2009/04/06/using-7-zip-and-batch-files-to-perform-backups-automatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

