<?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>zInformatik &#187; Backup</title>
	<atom:link href="http://zinformatik.de/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://zinformatik.de</link>
	<description>Computer, Informatik und Mikrocontroller Blog</description>
	<lastBuildDate>Sat, 22 Oct 2011 09:51:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Backup mit Linux Boardmitteln</title>
		<link>http://zinformatik.de/linux/backup-mit-linux-boardmitteln/</link>
		<comments>http://zinformatik.de/linux/backup-mit-linux-boardmitteln/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 22:12:16 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sicherheit und Datenschutz]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Konsole]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=904</guid>
		<description><![CDATA[<p>Ich mag die Kommandozeile und ich mag Standardwerkzeuge. Daher möchte ich hier ein paar Backuplösungen vorstellen, die nur mit Standardwerkzeugen auskommen.</p>
<p>Die Vorteile sind</p>
<ul>
<li>Die Werkzeuge sind auf fast jedem System Verfügbar</li>
<li>Die Werkzeuge sind im Allgmeinen sehr gut erprobt und enthalten quasi keine Bugs</li>
<li>Alles kann mit der Konsole gemacht werden. Also auch wenn man keine graphische Oberfläche</li></ul><p>&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Ich mag die Kommandozeile und ich mag Standardwerkzeuge. Daher möchte ich hier ein paar Backuplösungen vorstellen, die nur mit Standardwerkzeugen auskommen.</p>
<p>Die Vorteile sind</p>
<ul>
<li>Die Werkzeuge sind auf fast jedem System Verfügbar</li>
<li>Die Werkzeuge sind im Allgmeinen sehr gut erprobt und enthalten quasi keine Bugs</li>
<li>Alles kann mit der Konsole gemacht werden. Also auch wenn man keine graphische Oberfläche hat oder per ssh eingeloggt ist</li>
<li>Vieles kann mittels Bash-Scripts automatisiert werden</li>
<li>Die Backups können meistens auch unter schwierigen Umständen noch erstellt und eingespielt werden</li>
</ul>
<p><br clear="all" /><br />
<strong>Komplettes Festplatten-Image erstellen</strong></p>
<p>Um ein Komplettes Image der Festplatte zu erstellen kann man tar benuzten. Dies ist bei so ziemlich jeder Linux-Distribution standardmäßig installiert.</p>
<p>Man bootet mit einer LiveCD oder Knoppix CD. Wenn man einen Root-Server hat, kann man das Rescue-System (so heißt es bei Hetzner, andere Provider sollten jedoch ähnliches anbieten) booten. Nun erstellen wir ein Verzeichnis und mounten darin die Festplatte, die gesichert werden soll. Hat man sein System auf mehrere Partitionen verteilt, kann man diese an die entsprechenden Stellen einbinden oder von jeder einzelnen ein Backup machen. Das folgende Beispiel zeigt, wie man die Partition /dev/sda1 sichert. Die Datei liegt hinterher im Wurzelverzeichnis der Partition als image.tar.gz.  (Alle Befehle mit root-Rechten ausführen):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>system
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda1 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>system
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>rescue
<span style="color: #c20cb9; font-weight: bold;">tar</span> cvzpf image.tar.gz .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">--exclude</span>=image.tar.gz</pre></div></div>

<p>Diese Datei kann nun auf einen externen Datenträger, einen FTP-Server  oder eine andere Partition/Festplatte kopiert werden.</p>
<p>Ist auf /dev/sda1 nicht genug Platz, so kann man auch direkt auf eine andere Partition bzw. einen Wechelsdatenträger sichern. Im folgenden wird ein Backup von /dev/sda1 nach /dev/sda2 gemacht:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>system
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda1 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>system
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>backup
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda2 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>backup
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>backup
<span style="color: #c20cb9; font-weight: bold;">tar</span> cvzpf image.tar.gz <span style="color: #660033;">-C</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>system .<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Das Praktische an dieser Datei ist, dass man sie jederzeit wieder auf eine (neue) Festplatte aufspielen kann und das gesammte System wieder hergestellt ist (lediglich der Bootloader muss ggf. neu installiert werden). Dabei ist egal, ob der die Partition eine andere Größe hat (solange alles drauf passt) oder mit einem anderen Dateisystem formatiert ist.<br />
Das Einspielen des Backups geht nun folgendermaßen: Wieder Booten mit LiveCD oder im Rescue-System und dann:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>system
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda1 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>system
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>system
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>image.tar.gz .
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvzpf image.tar.gz</pre></div></div>

<p>Der Kopierbefehl muss entsprechend angepasst werden oder man entpackt direkt vom anderen Medium:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>system
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda1 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>system
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>backup
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda2 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>backup
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>backup
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvzpf image.tar.gz <span style="color: #660033;">-C</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>system</pre></div></div>

<p>Wi man Grub neu installiert ist auf dem Ubuntuusers Wiki im Artikel <a href="http://wiki.ubuntuusers.de/GRUB" title="Ubuntuusers Wiki - Grub" target="_blank" class="liuu">Grub</a> sehr gut beschrieben. (Ich gehe mal davon aus, dass lilo kaum noch genutzt wird und wer es noch nutzt, wird wissen wie man es neu installiert)</p>
<p><br clear="all" /><br />
<strong>Einzelne Verzeichnisse sichern</strong></p>
<p>Möchte man nur bestimmte Verzeichnisse sichern, so kann man auch tar verwenden. Im Prinzip geht dies genauso, nur dass man nicht unbedingt neu zu booten braucht. (Die Pfade müssen dann entsprechend angepasst werden und es braucht nichts gemountet werden. Verzeichnisse brauchen auch nur einmal am Anfang erstellt werden.) Ein <a href="http://wiki.ubuntuusers.de/Backupscript" title="Ubuntuusers Wiki - Backupscript" target="_blank" class="liuu">Backupscript mit tar</a> gibt es im Ubuntuusers Wiki. Ein weiteres sehr gutes Script mit vielen weiteren Optionen und automatischem FTP-Upload ist <a href="http://zinformatik.de/tipps-tricks/interessante-programme/backup-per-ftp-mit-tartarus/" title="Tartarus Backupscript" target="_self" class="liinternal">Tartarus</a> (Dies ist ein recht großes Bash Script, welches jedoch nur Standardwerkzeuge nutzt).<br />
Möchte man MySQL Datenbanken sichern, so sollte man vorher einen Dump machen und diesen sichern, da sich die Datenbank sonst in einem inkonsistenten Zustand befinden kann.<br />
Hier ein kleines Script, welches alle Datenbanken sichert:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Wohin sollen Datenbank Backups geschrieben werden?</span>
<span style="color: #007800;">DB_BACKUP_PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>pfad<span style="color: #000000; font-weight: bold;">/</span>zum<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>verzeichnis
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$DB_BACKUP_PATH</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Bereinigte Liste der Datenbanken erzeugen</span>
<span style="color: #666666; font-style: italic;">#ersetze passwort mit dem root-Passwort der MySQL Datenbank</span>
<span style="color: #007800;">DBASELIST</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">mktemp</span><span style="color: #000000; font-weight: bold;">`</span>
mysqlshow <span style="color: #660033;">-ppasswort</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> Databases <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$DBASELIST</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> x <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$DBASELIST</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #666666; font-style: italic;">#echo &quot;Datenbank: $x sichern&quot;;</span>
    mysqldump <span style="color: #660033;">--opt</span> <span style="color: #660033;">-ppasswort</span> <span style="color: #007800;">$x</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$x</span>.sql;
<span style="color: #000000; font-weight: bold;">done</span>;
&nbsp;
<span style="color: #666666; font-style: italic;"># Alte .gz-Dateien loeschen</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">*</span>.gz
&nbsp;
<span style="color: #666666; font-style: italic;"># Dateien zippen</span>
<span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<p><br clear="all" /><br />
<strong>Inkrementelles Backup mit rsync</strong></p>
<p>Möchte man regelmäßig ein Backup von zu Hause ziehen, so ist rsync die beste Wahl. Denn es werden nur Dateien kopiert, die sich geändert haben.<br />
rsync ist auch dann eine gute Wahl, wenn man die Möglichkeit hat auf einen Server mit ssh Zugriff zu sichern. Natürlich kann rsync aber auch in ein Verzeichnis sichern.<br />
Eine <a href="http://wiki.ubuntuusers.de/rsync" title="Ubuntuusers Wiki - rsync" target="_blank" class="liuu">ausführliche Erklärung zu rsync</a> gibt es im Ubuntuusers Wiki (und natürlich in der manpage). Ein <a href="http://www.heinlein-support.de/web/wissen/rsync-backup/" title="Heinlein Support - rsync Backup" target="_blank" class="liexternal">sehr gutes Backup-Script mit Erklärung</a> wurde von Heinlein online gestellt.<br />
Auch bei rsync-Backups ist bei Datenbanken darauf zu achten, dass vorher ein Dump erstellt und nur dieser gesichert wird.</p>
<p><br clear="all" /><br />
<strong>Meine Backuplösung</strong></p>
<p>Ich nutze Tartarus und rsync für die Backups.<br />
Für Tartarus habe ich 3 Configurationen eingerichtet: eine für die Webaccounts, eine für die Datenbanken und eine für Konfigurationsdateien (/etc). Bei den Datenbanken wird obiges Script als Pre-Hook vor dem eigentlichen Backup durchgeführt um nur die Dumps zu sichern. Die Backups werden symmetrisch GPG verschlüsselt, da sie per FTP auf den Backupserver geladen werden, der von Hetzner zur Verfügung steht. Es wird einmal die Woche ein volles Backup und jeden Tag dazwischen ein inkrementelles Backup der Daten erstellt. Backups, die älter als eine Woche sind, werden automatisch gelöscht.<br />
Mit rsync wird jeden Tag ein inkrementelles Backup zu mir nach Hause durchgeführt.</p>
]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/linux/backup-mit-linux-boardmitteln/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup per FTP mit Tartarus</title>
		<link>http://zinformatik.de/tipps-tricks/interessante-programme/backup-per-ftp-mit-tartarus/</link>
		<comments>http://zinformatik.de/tipps-tricks/interessante-programme/backup-per-ftp-mit-tartarus/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 22:17:47 +0000</pubDate>
		<dc:creator>zimon</dc:creator>
				<category><![CDATA[Interessante Programme]]></category>
		<category><![CDATA[Sicherheit und Datenschutz]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[Konsole]]></category>
		<category><![CDATA[Scripte]]></category>

		<guid isPermaLink="false">http://zinformatik.de/?p=554</guid>
		<description><![CDATA[<p>Bisher war der <a href="http://zinformatik.de/allgemeines/server-down-wegen-stromausfall-bei-hetzner/" title="Stromausfall bei Hetzner" target="_self" class="liinternal">Stromausfall am Donnerstag</a> das einzige mal seit ich dort Kunde bin, dass etwas bei Hetzner nicht in Ordnung war. Jedoch habe ich es mir zum Anlass genommen, meine Backupstrategie zu überdenken.</p>
<p>Bisher nutzte ich selbstgeschriebene Bash Scripte und wollte diese erweitern, doch dann stieß ich auf Tartarus.</p>
<p>Tartarus ist ein opensource&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>Bisher war der <a href="http://zinformatik.de/allgemeines/server-down-wegen-stromausfall-bei-hetzner/" title="Stromausfall bei Hetzner" target="_self" class="liinternal">Stromausfall am Donnerstag</a> das einzige mal seit ich dort Kunde bin, dass etwas bei Hetzner nicht in Ordnung war. Jedoch habe ich es mir zum Anlass genommen, meine Backupstrategie zu überdenken.</p>
<p>Bisher nutzte ich selbstgeschriebene Bash Scripte und wollte diese erweitern, doch dann stieß ich auf Tartarus.</p>
<p>Tartarus ist ein opensource Bash Script, welches komplette sowie inkrementelle Backups von beliebigen Ordnern machen kann. Auch LVM Snapshots sind möglich. Warum also Zeit in Scripten, Testen und Debuggen investieren (es soll ja auch zuverlässig sein), wenn es schon eine fertige und erprobte Lösung gibt&#8230;</p>
<p>Die Konfiguration lässt sich einfach über verschiedene Konfigurationsdateien steuern wodurch Änderungen schnell umgesetzt werden können.</p>
<p>Die Sicherung erfolgt wahlweise zu einem FTP-Server oder in ein Verzeichnis. Man kann jedoch noch andere Möglichkeiten nutzen indem man entsprechende Funktionen in den Konfigurationsdateien erstellt. In der Dokumentation ist ein Beispiel für ssh.</p>
<p>Die Verzeichnisse werden mit tar gepackt und wahlweise mit bzip2 oder gzip komprimiert. Zusätzlich kann noch mit GnuPG synchron oder asynchron verschlüsselt werden.Verzeichnisse, die nicht mit ins Backup sollen kann man über eine Liste ausschließen.</p>
<p>Die Verwendung von Standardbefehlen wie tar oder bzip finde ich sehr Vorteilhaft, da sie auf fast jedem (Linux) System verfügbar sind. Zur Übertragung per FTP wird curl genutzt.</p>
<p>Mit dem Zusatzscript charon kann man ältere Backups auch leicht wieder vom Backup-Server löschen. Dies kann man sogar als sogenannten &#8220;Hook&#8221; nach der Erstellung des neuen Backups automatisch ausführen lassen. Dabei löscht charon nur  Backups, die älter als eine vorgegebene Anzahl von Tagen sind.</p>
<p><strong>Links:</strong></p>
<ul>
<li>Tartarus Homepage: <a href="http://wertarbyte.de/tartarus.shtml" title="Tartarus Webpage" target="_blank" class="liexternal">http://wertarbyte.de/tartarus.shtml</a></li>
<li>Installations- und Konfigurationsanleitung im Hetzner Wiki: <a href="http://wiki.hetzner.de/index.php/Tartarus_Backup-Konfiguration" title="Hetzner Wiki - Tartarus" target="_blank" class="liexternal">http://wiki.hetzner.de/index.php/Tartarus_Backup-Konfiguration</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://zinformatik.de/tipps-tricks/interessante-programme/backup-per-ftp-mit-tartarus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

