<?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>controlc.de &#187; tar</title>
	<atom:link href="http://controlc.de/tag/tar/feed/" rel="self" type="application/rss+xml" />
	<link>http://controlc.de</link>
	<description>mehr als nur ein Notizblock</description>
	<lastBuildDate>Fri, 13 Jan 2012 18:37:18 +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>bash &#124; Backups mit tar</title>
		<link>http://controlc.de/2009/11/22/bash-backups-mit-tar/</link>
		<comments>http://controlc.de/2009/11/22/bash-backups-mit-tar/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 11:40:58 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[allgemeine IT]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=1041</guid>
		<description><![CDATA[In einem älteren Artikel habe ich mich schon mal damit beschäftigt, wie man in *nix-basierten Betriebssystemen leicht Backups anlegen kann. Da der Bedarf bei mir wieder mal akuter wurde, haber ich mich wieder mal damit beschäftigt und möchte hier erklären, wie man was machen kann. Backup von bestimmten Dateien Häufiger möchte man, wenn man mal [...]]]></description>
			<content:encoded><![CDATA[	<p><a href="http://controlc.de/wp-content/uploads/2009/11/Bash.png" class="floatbox" rev="group:1041 caption:`Bash`"><img class="aligncenter size-medium wp-image-1063" title="Bash" src="http://controlc.de/wp-content/uploads/2009/11/Bash-300x232.png" alt="Bash" width="300" height="232" /></a>In einem <a href="http://controlc.de/2009/05/20/bash-schnelles-backup-anlegen/">älteren Artikel</a> habe ich mich schon mal damit beschäftigt, wie man in *nix-basierten Betriebssystemen leicht Backups anlegen kann. Da der Bedarf bei mir wieder mal akuter wurde, haber ich mich wieder mal damit beschäftigt und möchte hier erklären, wie man was machen kann.</p>
	<h4><span id="more-1041"></span>Backup von bestimmten Dateien</h4>
	<p>Häufiger möchte man, wenn man mal schnell etwas in einer Config-Datei etwas ändert, davon fix ein Backup anlegen. Klassisch habe ich das meist schnell mit</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> DATEI.conf DATEI.conf.orig</pre></div></div>

	<p>gelöst. Was aber passiert, wenn man dann später nochmal was ändern will respektive ein neues Backup angelegt werden soll?! Wie man dieses Problem erschlägt, habe ich schon mal in <a href="http://controlc.de/2009/05/20/bash-schnelles-backup-anlegen/">diesem Artikel</a> erklärt — das war aber nur ein Schnellschuß. Das Problem dabei ist nämlich, das man ja jeweils die alten Backups nochmal mitsichert und dadurch die Backups immer größer werden. Dies kann man durch einen Exclude-Parameter von tar auschließen. Der Befehl um in einem Verzeichnis alle Dateien zu sichern lautet also</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-cz</span> <span style="color: #660033;">--no-recursion</span> <span style="color: #660033;">--exclude</span>=backup-<span style="color: #000000; font-weight: bold;">*</span>.tar.gz <span style="color: #660033;">-f</span> backup-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>F-<span style="color: #000000; font-weight: bold;">%</span>H-<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #7a0874; font-weight: bold;">&#41;</span>.tar.gz <span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

	<h4>Backup von ganzen Pfaden inkl. der Unterverzeichnisse</h4>
	<p>In einigen Fällen will man nicht nur die Dateien in einem Verzeichnis sichern sondern lieber gleich den Inhalt gesamte Verzeichnis inklusive aller Unterverzeichnisse</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-cz</span> <span style="color: #660033;">--exclude</span>=backup-<span style="color: #000000; font-weight: bold;">*</span>.tar.gz <span style="color: #660033;">-f</span> backup-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>F-<span style="color: #000000; font-weight: bold;">%</span>H-<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #7a0874; font-weight: bold;">&#41;</span>.tar.gz .</pre></div></div>

	<h4>Backup von Dateien bzw. Pfaden, die im gesamten System verteilt sind</h4>
	<p>Und schließlich hat man den Fall, das man alle wichtigen Dateien eines Systems sichern will, die aber über das gesamte System verteilt sind. Dies erreicht man mit einer Include-Datei</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> cvzf <span style="color: #000000; font-weight: bold;">/</span>backup-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>F-<span style="color: #000000; font-weight: bold;">%</span>T<span style="color: #7a0874; font-weight: bold;">&#41;</span>.tar.gz <span style="color: #660033;">-T</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>backup-include-dir.conf</pre></div></div>

	<p>wobei man in die Datei <em>/etc/backup-include-dir.conf</em> alle Pfade bzw. alle Dateien reinschreibt, die gesichert werden sollen. Wichtig ist dabei nur: Pro Datei/Pfad jeweils eine Zeile.</p>
	<p>Und denkt daran: Solche Befehlszeilen eignen sich wunderbar dazu als alias definiert zu werden, damit man schnell drauf zugreifen kann, wenn man es mal braucht.
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2009/11/22/bash-backups-mit-tar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bash &#124; schnelles Backup anlegen</title>
		<link>http://controlc.de/2009/05/20/bash-schnelles-backup-anlegen/</link>
		<comments>http://controlc.de/2009/05/20/bash-schnelles-backup-anlegen/#comments</comments>
		<pubDate>Wed, 20 May 2009 09:27:35 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[allgemeine IT]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://controlc.de/?p=420</guid>
		<description><![CDATA[Bei Jann habe ich Folgendes unter dem Stichwort In der Shell schnell mal alle Dateien im Verzeichnis nach *.bak sichern gelesen: Kurznotiz, gilt für Mac / Linux / Unix / (bei Windows hilft nur “format c:” ) Oft muss ich in einem Ordner schnell mal alle Dateien sichern als Backup da ich sie im nächsten [...]]]></description>
			<content:encoded><![CDATA[	<p>Bei <a href="http://adminday.de">Jann</a> habe ich Folgendes unter dem Stichwort <a href="http://adminday.de/tutorials-und-tipps/in-der-shell-schnell-mal-alle-dateien-im-verzeichnis-nach-bak-sichern/">In der Shell schnell mal alle Dateien im Verzeichnis nach *.bak sichern</a> gelesen:</p>
	<blockquote><p>Kurznotiz, gilt für Mac / Linux / Unix / (bei Windows hilft nur “format c:” <img class="wp-smiley" src="http://adminday.de/wp-includes/images/smilies/icon_wink.gif" alt=";)" /> )<br />
Oft muss ich in einem Ordner schnell mal alle Dateien sichern als Backup da ich sie im nächsten Moment überschreibe.  Um nicht den ganzen übergeordneten Ordner gleich komplett sichern zu müssen sondern nur die Dateien im aktuellen Ordner <span style="text-decoration: underline;">ohne Unterverzeichnisse</span> zu sichern habe ich folgenden befehl:<br />
for i in *.*; do cp $i $i.bak ;done<br />
Alle Dateien im Ordner werden dann von xyz.txt nach xyz.txt.bak kopiert, wer anstelle des kopieren die Daten verschieben will ersetzt im script einfach “cp” mit “mv”  Wer in einem Verzeichnis nur bestimmte Dateitypen z.B. *.html sichern mag macht dies dann so:<br />
for i in *.html; do cp $i $i.bak ; done<br />
somit werden an alle *.html Dateien im Ordner nach *.html.bak gesichert  Das gleiche geht mit jedem beliebigen Dateityp ^^</p></blockquote>
	<p>Lange habe ich drüber nachgedacht, da ich den Ansatz etwas zu kompliziert finde und da ich gerade in dem Buch <a href="http://www.oreilly.de/catalog/bash3ger/index.html">Einführung in die BASH</a> lese und mal schauen wollte, was davon bei mir hängen geblieben ist, habe ich folgendes ausprobiert:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-cz</span> <span style="color: #660033;">--no-recursion</span> <span style="color: #660033;">-f</span> backup-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>F-<span style="color: #000000; font-weight: bold;">%</span>H-<span style="color: #000000; font-weight: bold;">%</span>M<span style="color: #7a0874; font-weight: bold;">&#41;</span>.tar.gz <span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

	<p>Das Ganze als Alias definiert mit Übergabe der Dateiextension sieht dann so aus:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">archive</span>=<span style="color: #ff0000;">'tar -cz --no-recursion -f backup-$(date +%F-%H-%M).tar.gz $1'</span></pre></div></div>

	<p>Damit kann man später schnell mit</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">archive <span style="color: #000000; font-weight: bold;">*</span>.html</pre></div></div>

	<p>schnell alle HTML-Files eines Verzeichnisses sichern und weiß gleich von wann die Sicherung ist.
</p>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2009/05/20/bash-schnelles-backup-anlegen/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>debian &#124; Backup per SSH</title>
		<link>http://controlc.de/2009/05/06/backup-per-ssh/</link>
		<comments>http://controlc.de/2009/05/06/backup-per-ssh/#comments</comments>
		<pubDate>Wed, 06 May 2009 12:09:58 +0000</pubDate>
		<dc:creator>controlc.de</dc:creator>
				<category><![CDATA[allgemeine IT]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[cat]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://controlc.de/wordpress/?p=94</guid>
		<description><![CDATA[So ein Server will ja auch mal »gebackupt« werden — am einfachsten geht das über eine Shell-Befehlszeile: tar cvzf - -T /root/backup-liste-include.txt &#124; ssh BENUTZER@SERVER &#34;cat &#62; /root/backup-$(date +%F-%T).tar.gz&#34; in der Datei /root/backup-liste-include.txt sollte jeder Pfad in einer einzelnen Zeile stehen, so kann man das Backup schnell erweitern. Was macht die Befehlszeile genau? Es packt [...]]]></description>
			<content:encoded><![CDATA[	<p>So ein Server will ja auch mal »gebackupt« werden — am einfachsten geht das über eine Shell-Befehlszeile:</p>
	
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> cvzf - <span style="color: #660033;">-T</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>backup-liste-include.txt <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> BENUTZER<span style="color: #000000; font-weight: bold;">@</span>SERVER <span style="color: #ff0000;">&quot;cat &gt; /root/backup-<span style="color: #007800;">$(date +%F-%T)</span>.tar.gz&quot;</span></pre></div></div>

	<p><span id="more-94"></span></p>
	<p>in der Datei /root/backup-liste-include.txt sollte jeder Pfad in einer einzelnen Zeile stehen, so kann man das Backup schnell erweitern.</p>
	<p>Was macht die Befehlszeile genau? Es packt die entsprechenden Pfad ein und »cat»tet diese Datei per SSH auf einen anderen, per SSH erreichbaren Server wieder aus. Die dort entstehende Datei trägt den Dateiennamen des aktuellen Datums und der aktuellen Uhrzeit, z.B. <em>backup-2009–05-06–14:06:55.tar.gz</em></p>
	<p>ToDo:</p>
	<ul>
	<li>Eine Lösung per SSH-Keys, damit es automatisch ablaufen kann</li>
	<li>Eintragung in cron</li>
	<li>Logrotate o.ä., damit ältere Backups automatisch gelöscht werden</li>
	</ul>
]]></content:encoded>
			<wfw:commentRss>http://controlc.de/2009/05/06/backup-per-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

