<?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>EmanuelDuss.ch. &#187; shell</title>
	<atom:link href="http://emanuelduss.ch/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://emanuelduss.ch</link>
	<description>blog von @mindfuckup</description>
	<lastBuildDate>Thu, 26 Jan 2012 19:08:43 +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>Wikipedia-Einträge über DNS abfragen</title>
		<link>http://emanuelduss.ch/2011/02/wikipedia-eintrage-abfragen/</link>
		<comments>http://emanuelduss.ch/2011/02/wikipedia-eintrage-abfragen/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 20:31:22 +0000</pubDate>
		<dc:creator>Emanuel Duss</dc:creator>
				<category><![CDATA[Konsolentricks]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[konsole]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://emanuelduss.ch/?p=113</guid>
		<description><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2011/02/wikipedia-eintrage-abfragen/&amp;text=Wikipedia-Einträge über DNS abfragen&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
Die Online-Enzyklopädie Wikipedia kann über DNS abgefragt werden. Toll daran ist, dass man somit jederzeit die Definition von einem Begriff aus der Shell heraus per DNS abfragen kann. Technik Der DNS-Server wp.dg.cx stellt über TXT-Ressource-Records den ersten Absatz von den englischen Wikipedia-Artikeln zur Verfügung. Der DNS-Server kann mit nslookup oder dig abgefragt werden. Abfrage Ich [...]]]></description>
			<content:encoded><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2011/02/wikipedia-eintrage-abfragen/&amp;text=Wikipedia-Einträge über DNS abfragen&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
<p>Die Online-Enzyklopädie Wikipedia kann über DNS abgefragt werden. Toll daran ist, dass man somit jederzeit die Definition von einem Begriff aus der Shell heraus per DNS abfragen kann.<br />
<span id="more-113"></span><br />
<strong>Technik</strong><br />
Der DNS-Server <em>wp.dg.cx</em> stellt über TXT-Ressource-Records den ersten Absatz von den englischen Wikipedia-Artikeln zur Verfügung. Der DNS-Server kann mit <em>nslookup</em> oder <em>dig</em> abgefragt werden.</p>
<p><strong>Abfrage</strong><br />
Ich möchte die Definition von <em>Foo</em> wissen. Der DNS-Query sieht folgendermassen aus:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@discordia:~<br />
$ dig foo.wp.dg.cx TXT<br />
;; Truncated, retrying in TCP mode.<br />
<br />
; &lt;&lt;&gt;&gt; DiG 9.7.2-P3 &lt;&lt;&gt;&gt; txt foo.wp.dg.cx<br />
;; global options: +cmd<br />
;; Got answer:<br />
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 7560<br />
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 13, ADDITIONAL: 1<br />
<br />
;; QUESTION SECTION:<br />
;foo.wp.dg.cx. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IN &nbsp; &nbsp; &nbsp;TXT<br />
<br />
;; ANSWER SECTION:<br />
foo.wp.dg.cx. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 86400 &nbsp; IN &nbsp; &nbsp; &nbsp;TXT &nbsp; &nbsp; &quot;The term foobar, <br />
along with foo, bar, and baz, is a common placeholder name <br />
(also referred to as a metasyntactic variable) used in computer <br />
programming or computer-related documentation. These four <br />
terms are used heavily in computer science to take the pl&quot; &quot;ace <br />
of unknown values, typically while describing a scenario where <br />
the purpose of the unknown values are understood, but... <br />
http://a.vu/w:Foobar&quot;<br />
<br />
;; AUTHORITY SECTION:<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;g.root-servers.net.<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;f.root-servers.net.<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;h.root-servers.net.<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;e.root-servers.net.<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;k.root-servers.net.<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;l.root-servers.net.<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;j.root-servers.net.<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;c.root-servers.net.<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;a.root-servers.net.<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;m.root-servers.net.<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;i.root-servers.net.<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;b.root-servers.net.<br />
. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 78741 &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;d.root-servers.net.<br />
<br />
;; ADDITIONAL SECTION:<br />
a.root-servers.net. &nbsp; &nbsp; 79004 &nbsp; IN &nbsp; &nbsp; &nbsp;A &nbsp; &nbsp; &nbsp; 198.41.0.4<br />
<br />
;; Query time: 5 msec<br />
;; SERVER: 10.0.0.10#53(10.0.0.10)<br />
;; WHEN: Mon Feb 14 21:11:04 2011<br />
;; MSG SIZE &nbsp;rcvd: 670</div></div>
<p>In der Answer-Section steht die Erklärung von Foo.</p>
<p><strong>Darstellung</strong><br />
Um nur die nötigen Informationen von <em>dig</em> zu erhalten, verwendet man die Option <em>+short</em>:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@discordia:~<br />
$ dig +noall +short foo.wp.dg.cx TXT<br />
;; Truncated, retrying in TCP mode.<br />
&quot;The term foobar, along with foo, bar, and baz, is a common <br />
placeholder name (also referred to as a metasyntactic variable)<br />
used in computer programming or computer-related documentation.<br />
These four terms are used heavily in computer science to take the<br />
pl&quot; &quot;ace of unknown values, typically while describing a scenario <br />
where the purpose of the unknown values are understood, but... <br />
http://a.vu/w:Foobar&quot;</div></div>
<p>Um die erste Zeile zu entfernen, hilft die Option <em>+ignore</em>:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@discordia:~<br />
$ dig +ignore +short foo.wp.dg.cx TXT<br />
&quot;The term foobar, along with foo, bar, and baz, is a common <br />
placeholder name (also referred to as a metasyntactic variable)<br />
used in computer programming or computer-related documentation.<br />
These four terms are used heavily in computer science to take the<br />
pl&quot; &quot;ace of unknown values, typically while describing a scenario <br />
where the purpose of the unknown values are understood, but... <br />
http://a.vu/w:Foobar&quot;</div></div>
<p>So ist die Ausgabe angenehmer zu lesen.</p>
<p><strong>Automatisieren</strong><br />
Ich habe mir folgende Funkton in die Datei <em>~/.bashrc</em> geschrieben, damit ich Wikipedia schnell aus der Konsole heraus abfragen kann:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">wiki<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">dig</span> +ignore +short <span style="color: #007800;">$1</span>.wp.dg.cx TXT<br />
&nbsp; <span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> Bitte einen Begriff angeben.<br />
&nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span></div></div>
<p>Wenn man eine neue Bash startet, wird diese Funktion geladen und sie kann verwendet werden:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@discordia:~<br />
$ wiki foo<br />
&quot;The term foobar, along with foo, bar, and baz, is a common <br />
placeholder name (also referred to as a metasyntactic variable)<br />
used in computer programming or computer-related documentation.<br />
These four terms are used heavily in computer science to take the<br />
pl&quot; &quot;ace of unknown values, typically while describing a scenario <br />
where the purpose of the unknown values are understood, but... <br />
http://a.vu/w:Foobar&quot;</div></div>
<p>Das ist doch praktisch!</p>
 <p><a href="http://emanuelduss.ch/?flattrss_redirect&amp;id=113&amp;md5=a50124d27e134e01236bd829ef49499a" title="Flattr" target="_blank"><img src="http://emanuelduss.ch/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://emanuelduss.ch/2011/02/wikipedia-eintrage-abfragen/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<atom:link rel="payment" href="http://emanuelduss.ch/?flattrss_redirect&amp;id=113&amp;md5=a50124d27e134e01236bd829ef49499a" type="text/html" />
	</item>
		<item>
		<title>Fotos nach Datum umbenennen mit jhead</title>
		<link>http://emanuelduss.ch/2011/02/fotos-umbenennen-mit-jhead/</link>
		<comments>http://emanuelduss.ch/2011/02/fotos-umbenennen-mit-jhead/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 17:10:55 +0000</pubDate>
		<dc:creator>Emanuel Duss</dc:creator>
				<category><![CDATA[Multimedia]]></category>
		<category><![CDATA[Skripts]]></category>
		<category><![CDATA[fotos]]></category>
		<category><![CDATA[jhead]]></category>
		<category><![CDATA[konsole]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://emanuelduss.ch/?p=316</guid>
		<description><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2011/02/fotos-umbenennen-mit-jhead/&amp;text=Fotos nach Datum umbenennen mit jhead&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
Digitalkameras speichern Bilder oft unter Dateinamen wie DSC00523.jpg. Mit diesen nicht sprechenden Namen kann ich nicht viel anfangen. Das Datum und die Uhrzeit des Fotos ist für den Dateinamen viel besser geeignet. EXIF-Daten auslesen Die Digitalkamera speichert das Datum und die Uhrzeit in den so genannten EXIF-Tags. Mit jhead kann man diese Tags auslesen und [...]]]></description>
			<content:encoded><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2011/02/fotos-umbenennen-mit-jhead/&amp;text=Fotos nach Datum umbenennen mit jhead&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
<p>Digitalkameras speichern Bilder oft unter Dateinamen wie DSC00523.jpg. Mit diesen nicht sprechenden Namen kann ich nicht viel anfangen. Das Datum und die Uhrzeit des Fotos ist für den Dateinamen viel besser geeignet.<br />
<span id="more-316"></span></p>
<p><strong>EXIF-Daten auslesen</strong><br />
Die Digitalkamera speichert das Datum und die Uhrzeit in den so genannten EXIF-Tags. Mit jhead kann man diese Tags auslesen und bearbeiten.</p>
<p>Mit <em>jhead dateiname.jpg</em> kann man sich die EXIF-Tags anzeigen lassen:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@discordia:~<br />
$ jhead DSC00523.JPG<br />
File name &nbsp; &nbsp;: DSC00523.JPG<br />
File size &nbsp; &nbsp;: 2277972 bytes<br />
File date &nbsp; &nbsp;: 2011:02:06 13:45:34<br />
Camera make &nbsp;: Canon<br />
Camera model : Canon DIGITAL IXUS 80 IS<br />
Date/Time &nbsp; &nbsp;: 2010:12:27 12:02:37<br />
Resolution &nbsp; : 2592 x 1944<br />
Flash used &nbsp; : No<br />
Focal length : 14.3mm &nbsp;(35mm equivalent: 90mm)<br />
CCD width &nbsp; &nbsp;: 5.72mm<br />
Exposure time: 0.020 s &nbsp;(1/50)<br />
Aperture &nbsp; &nbsp; : f/4.5<br />
Focus dist. &nbsp;: 6.57m<br />
ISO equiv. &nbsp; : 800<br />
Whitebalance : Auto<br />
Metering Mode: pattern</div></div>
<p>In der Zeile <em>Date/Time</em> sieht man, dass das Foto am 27.12.2010 um 12:02:37h erstellt wurde.</p>
<p><strong>Datei umbenennen</strong><br />
Mit <em>jhead</em> kann man nun das Foto nach dem Muster YYYY-mm-dd-HH-MM-SS umbenennen. Dies geschieht mit der Option <em>-nf</em> von <em>jhead</em>.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@discordia:~<br />
$ jhead -nf%Y-%m-%d_%H-%M-%S DSC00523.JPG<br />
DSC00523.JPG --&gt; 2010-12-27_12-02-37.jpg</div></div>
<p>Kann das Erstellungsdatum und die Erstelungsuhrzeit nicht aus den EXIF-Daten herausgelesen werden, wird der Zeitstempel der Datei verwendet.</p>
<p>In der Manpage von <em>jhead</em> sieht man, wie sich der Format-String zusammensetzen lässt:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">%H Hour in 24-hour format (00 - 23)<br />
%j Day of year as decimal number (001 - 366)<br />
%m Month as decimal number (01 - 12)<br />
%M Minute as decimal number (00 - 59)<br />
%S Second as decimal number (00 - 59)<br />
%w Weekday as decimal number (0 - 6; Sunday is 0)<br />
%y Year without century, as decimal number (00 - 99)<br />
%Y Year with century, as decimal number</div></div>
<p><strong>Alle Fotos in einem Ordner umbenennen</strong><br />
Mit dem regulären Ausdruck <em>*.[jJ][pP][gG]</em> benennt <em>jhead</em> alle Fotos in einem Ordner um:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@discordia:~<br />
$ jhead -nf%Y-%m-%d_%H-%M-%S *.[jJ][pP][gG]</div></div>
<p><strong>Alle Fotos umbenennen</strong><br />
Mit <em>find</em> kann man die gesamte Bildersammlung auf einmal umbenenen:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@discordia:~<br />
$ find Daten/Bilder -iname *.jpg -exec jhead -nf%Y-%m-%d_%H-%M-%S {} \;</div></div>
<p>Im Ordner <em>Daten/Bilder</em> sind alle Fotos gespeichert, welche umbenannt werden.</p>
<p><strong>Automatisieren</strong><br />
Damit man nicht jedes mal den Befehl von <em>jhead</em> eingeben muss, kann man sich ein Skript schreiben:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
<span style="color: #666666; font-style: italic;">########################################################################</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># imagerename</span><br />
<span style="color: #666666; font-style: italic;"># Fotos nach Datum umbenennen</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># 2009-01-01; Emanuel Duss; Erste Version</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;">########################################################################</span><br />
<br />
<span style="color: #666666; font-style: italic;">########################################################################</span><br />
<span style="color: #666666; font-style: italic;"># Main</span><br />
jhead -nf<span style="color: #000000; font-weight: bold;">%</span>Y-<span style="color: #000000; font-weight: bold;">%</span>m-<span style="color: #000000; font-weight: bold;">%</span>d_<span style="color: #000000; font-weight: bold;">%</span>H-<span style="color: #000000; font-weight: bold;">%</span>M-<span style="color: #000000; font-weight: bold;">%</span>S <span style="color: #000000; font-weight: bold;">*</span>.<span style="color: #7a0874; font-weight: bold;">&#91;</span>jJ<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>pP<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>gG<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># EOF</span></div></div>
<p>Ist dieses Skript ausführbar unter dem Dateinamen <em>imagerename</em> gespeichert und durch die Variable <em>$PATH</em> auffindbar, kann man in jedem Verzeichnis durch den Aufruf von <em>imagerename</em> alle Bilder im aktuellen Verzeichnis umbenennen.</p>
<p>Man kann sich aber auch einen Alias erstellen, welcher den Befehl ausführt. Folgende Zeile schreibt man sich in die Datei <em>~/.bashrc</em>:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">alias imagerename='jhead -nf%Y-%m-%d_%H-%M-%S *.[jJ][pP][gG]'</div></div>
<p>Auch jetzt kann man im jedem Verzeichnis durch <em>imagerename</em> alle Fotos umbenennen.</p>
 <p><a href="http://emanuelduss.ch/?flattrss_redirect&amp;id=316&amp;md5=29b8322486575385a1aa8642fc9b82e7" title="Flattr" target="_blank"><img src="http://emanuelduss.ch/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://emanuelduss.ch/2011/02/fotos-umbenennen-mit-jhead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://emanuelduss.ch/?flattrss_redirect&amp;id=316&amp;md5=29b8322486575385a1aa8642fc9b82e7" type="text/html" />
	</item>
		<item>
		<title>Manpages farbig darstellen</title>
		<link>http://emanuelduss.ch/2011/01/manpages-farbig-darstellen/</link>
		<comments>http://emanuelduss.ch/2011/01/manpages-farbig-darstellen/#comments</comments>
		<pubDate>Sun, 30 Jan 2011 18:38:27 +0000</pubDate>
		<dc:creator>Emanuel Duss</dc:creator>
				<category><![CDATA[Konfigurationsdateien]]></category>
		<category><![CDATA[Konfigurationsdatei]]></category>
		<category><![CDATA[konsole]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://emanuelduss.ch/?p=300</guid>
		<description><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2011/01/manpages-farbig-darstellen/&amp;text=Manpages farbig darstellen&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
Ich mag es, wenn meine Konsole farbig dargestellt wird. So finde ich es auch praktisch, wenn bestimmte Schlüsselwörter in Manpages farbig hervorgehoben werden. Anleitung Mit folgenden Befehlen kann man den Pager less dazu bringen, die Ausgaben anders zu formatieren: export LESS_TERMCAP_us=$'\E[01;32m' &#160; &#160; &#160; # Beginn unterstrichen export LESS_TERMCAP_ue=$'\E[0m' &#160; &#160; &#160; &#160; &#160; # [...]]]></description>
			<content:encoded><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2011/01/manpages-farbig-darstellen/&amp;text=Manpages farbig darstellen&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
<p>Ich mag es, wenn meine Konsole farbig dargestellt wird. So finde ich es auch praktisch, wenn bestimmte Schlüsselwörter in Manpages farbig hervorgehoben werden.<br />
<span id="more-300"></span><br />
<strong>Anleitung</strong><br />
Mit folgenden Befehlen kann man den Pager <em>less</em> dazu bringen, die Ausgaben anders zu formatieren:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LESS_TERMCAP_us</span>=$<span style="color: #ff0000;">'\E[01;32m'</span> &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Beginn unterstrichen</span><br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LESS_TERMCAP_ue</span>=$<span style="color: #ff0000;">'\E[0m'</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Ende unterstrichen</span><br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LESS_TERMCAP_so</span>=$<span style="color: #ff0000;">'\E[01;44;33m'</span> &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># Beginn Standout-Mode</span><br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LESS_TERMCAP_se</span>=$<span style="color: #ff0000;">'\E[0m'</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Ende Standout-Mode</span><br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LESS_TERMCAP_md</span>=$<span style="color: #ff0000;">'\E[01;31m'</span> &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Start fett</span><br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LESS_TERMCAP_mb</span>=$<span style="color: #ff0000;">'\E[01;31m'</span> &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Start blinken</span><br />
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LESS_TERMCAP_me</span>=$<span style="color: #ff0000;">'\E[0m'</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Ende alles</span></div></div>
<p>Diese Befehle schreibt man sich in die Datei <em>~/.bashrc</em>, die automatisch bei jeder neuen Shell ausgeführt wird.<br />
Mehr Informationen über die Variabeln <em>LESS_TERMCAP_xx</em> findet man in der Manpage <em>termcap</em>. Die Farben werden über <a href="http://ascii-table.com/ansi-escape-sequences.php">ANSI-Escape-Codes</a> definiert.</p>
<p><strong>Beispiel</strong><br />
Hier ein Beispiel anhand der Manpage von <em>man</em>:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ man man</div></div>
<p><a href="http://emanuelduss.ch/wp-content/uploads/2011/01/man_color.png" rel="lightbox[300]"><img class="alignnone size-medium wp-image-302" title="man_color" src="http://emanuelduss.ch/wp-content/uploads/2011/01/man_color-300x177.png" alt="" width="300" height="177" /></a><br />
Der Text, der normalerweise fett dargestellt wird, ist jetzt rot, und der unterstrichene Text ist jetzt grün.</p>
<p><strong>Weitere Informationen</strong><br />
Gefunden habe ich diesen Tipp im Planeten von Arch Linux und stammt aus der Zsh-Konfiguration von Grml, welche unter der Lizenz GPL v2 veröffentlicht wurde.</p>
<ul>
<li><a href="http://ascii-table.com/ansi-escape-sequences.php">ANSI-Escape-Codes</a></li>
<li><a href="https://bbs.archlinux.de/viewforum.php?id=362">Planet Forum von Arch Linux</a></li>
<li><a href="https://bbs.archlinux.de/viewtopic.php?id=18216">Arch Linux Planet &#8220;Farbige Manages auf der Konsole&#8221;</a></li>
<li><a href="http://grml.org/">Grml.org</a></li>
<li><a href="http://git.grml.org/?p=grml-etc-core.git;a=blob;f=etc/zsh/zshrc;h=0b82cb3300004853a06774c1b50fb46b83d4eeea;hb=dc4eb5bb4a81c8dbe312bd0f79721fe3a3dd6af8">Zsh-Konfiguration von Grml</a></li>
</ul>
 <p><a href="http://emanuelduss.ch/?flattrss_redirect&amp;id=300&amp;md5=bc954d4e2a8a085cd133c1d894fb958a" title="Flattr" target="_blank"><img src="http://emanuelduss.ch/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://emanuelduss.ch/2011/01/manpages-farbig-darstellen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://emanuelduss.ch/?flattrss_redirect&amp;id=300&amp;md5=bc954d4e2a8a085cd133c1d894fb958a" type="text/html" />
	</item>
		<item>
		<title>Fotos automatisch drehen mit jhead</title>
		<link>http://emanuelduss.ch/2011/01/fotos-automatisch-drehen-mit-jhead/</link>
		<comments>http://emanuelduss.ch/2011/01/fotos-automatisch-drehen-mit-jhead/#comments</comments>
		<pubDate>Sun, 16 Jan 2011 18:56:47 +0000</pubDate>
		<dc:creator>Emanuel Duss</dc:creator>
				<category><![CDATA[Konsolentricks]]></category>
		<category><![CDATA[Multimedia]]></category>
		<category><![CDATA[Skripts]]></category>
		<category><![CDATA[fotos]]></category>
		<category><![CDATA[jhead]]></category>
		<category><![CDATA[konsole]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://emanuelduss.ch/?p=75</guid>
		<description><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2011/01/fotos-automatisch-drehen-mit-jhead/&amp;text=Fotos automatisch drehen mit jhead&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
Viele Digitalkameras verfügen über einen Gravitationssensor, der erkennt, wie die Kamera beim erstellen des Bildes gehalten wurde. Diese Information kann man dazu nutzen, um das Bild automatisch richtig zu drehen. Die Information wird im EXIF-Tag &#8220;Orientation&#8221; des Bildes gespeichert. Mit dem Tool jhead kann man diese Information auslesen und das Foto automatisch drehen lassen. EXIF-Daten [...]]]></description>
			<content:encoded><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2011/01/fotos-automatisch-drehen-mit-jhead/&amp;text=Fotos automatisch drehen mit jhead&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
<p>Viele Digitalkameras verfügen über einen Gravitationssensor, der erkennt, wie die Kamera beim erstellen des Bildes gehalten wurde. Diese Information kann man dazu nutzen, um das Bild automatisch richtig zu drehen. Die Information wird im EXIF-Tag &#8220;Orientation&#8221; des Bildes gespeichert. Mit dem Tool <em>jhead</em> kann man diese Information auslesen und das Foto automatisch drehen lassen.<br />
<span id="more-75"></span><br />
<strong>EXIF-Daten</strong><br />
Wird <em>jhead</em> keine Option angegeben, werden einige EXIF-Informationen angezeigt:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ jhead foto.jpg <br />
File name &nbsp; &nbsp;: foto.jpg<br />
File size &nbsp; &nbsp;: 2040209 bytes<br />
File date &nbsp; &nbsp;: 2011:01:16 18:22:37<br />
Camera make &nbsp;: Canon<br />
Camera model : Canon DIGITAL IXUS 80 IS<br />
Date/Time &nbsp; &nbsp;: 2011:01:14 23:05:42<br />
Resolution &nbsp; : 2592 x 1944<br />
Orientation &nbsp;: rotate 90<br />
Flash used &nbsp; : Yes (auto)<br />
Focal length : &nbsp;6.2mm &nbsp;(35mm equivalent: 39mm)<br />
CCD width &nbsp; &nbsp;: 5.72mm<br />
Exposure time: 0.017 s &nbsp;(1/60)<br />
Aperture &nbsp; &nbsp; : f/2.8<br />
Focus dist. &nbsp;: 0.48m<br />
ISO equiv. &nbsp; : 250<br />
Whitebalance : Auto<br />
Metering Mode: pattern</div></div>
<p>Das Tag &#8220;Orientation&#8221; sagt, dass das Bild um 90° gedreht wurde. Aber jetzt weiss man immer noch nicht, ob das Bild im Uhrzeigersinn, oder im Gegenuhrzeigersinn gedreht werden muss.</p>
<p>Noch mehr Informationen kann man <em>jhead</em> mit der Option <em>-v</em> entlocken:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ jhead -v foto.jpg &nbsp;| grep -i orientation<br />
&nbsp; &nbsp; Orientation = 6<br />
Orientation &nbsp;: rotate 90</div></div>
<p>Das Orientation-Tag beseitzt den Wert 6. In den Spezifikationen von den EXIF-Tags steht folgendes dazu:</p>
<blockquote><p>The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.</p></blockquote>
<p>Daraus lässt sich schliessen, dass das Bild um 90° im Uhrzeigersinn gedreht werden muss.</p>
<p><strong>Das Foto drehen</strong><br />
Mit der Option <em>-autorot</em> kann <em>jhead</em> das Foto automatisch drehen.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ jhead -autorot foto.jpg <br />
Modified: foto.jpg</div></div>
<p>Das eigentliche Rotieren übernimmt nicht <em>jhead</em>, sondern <em>jpegtran</em>.</p>
<p>Das Orientation-EXIF-Tag besitzt nun den Wert 1. Das Bild muss also nicht mehr gedreht werden.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ jhead -v foto.jpg &nbsp;| grep -i orient<br />
&nbsp; &nbsp; Orientation = 1</div></div>
<p><strong>Orientation-Tag entfernen</strong><br />
Möchte man ein Foto nicht rotieren, aber das Orientation-EXIF-Tag trotzdem entfernen, kann man das mit der Option <em>-norot</em> machen:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ jhead -norot anderesfoto.jpg</div></div>
<p><strong>Alle Fotos in einem Verzeichnis drehen </strong><br />
Meistens will ich alle Fotos in einem Verzeichnis richtig drehen. Das kann man folgendermassen machen:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ jhead -autorot *.[jJ][pP][gG]</div></div>
<p>Die Shell löst den regulären Ausdruck <em>*.[jJ][pP][gG]</em> auf, und übergibt alle passenden Dateinamen an <em>jhead</em> weiter.</p>
<p>Diesen Befehl habe ich in einem Skript, damit ich jederzeit jhead so aufrufen kann:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#!/bin/bash<br />
################################################################<br />
#<br />
# imagerotate<br />
# Dreht Fotos anhand des EXIF-Tag Orientation<br />
#<br />
# 2011-01-16; Emanuel Duss; Erste Version<br />
#<br />
################################################################<br />
<br />
################################################################<br />
# Main<br />
jhead -autorot *.[jJ][pP][gG]<br />
<br />
# EOF</div></div>
<p>Natürlich kann man auch einen Alias in der <em>.bashrc</em> eintragen:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">alias imagerotate=&quot;jhead -autorot *.[jJ][pP][gG]&quot;</div></div>
<p><strong>Alle Fotos drehen</strong><br />
Folgendermassen kann man alle Bilder, welche sich im Ordner &#8220;~/Bilder&#8221; befinden automatisch drehen:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ find ~/Bilder -type f -name *.[jJ][pP][gG] -exec jhead -autorot {} \;</div></div>
<p>Somit ist die gesamte Bildersammlung richtig gedreht.</p>
<p><strong>Links und weitere Informationen</strong></p>
<ul>
<li>EXIF Spezifikationen: <a href="http://www.exif.org/specifications.html" target="_blank">http://www.exif.org/specifications.html</a></li>
<li>Projektseite von <em>jhead</em>: <a href="http://www.sentex.net/~mwandel/jhead/" target="_blank">http://www.sentex.net/~mwandel/jhead/</a>
</ul>
 <p><a href="http://emanuelduss.ch/?flattrss_redirect&amp;id=75&amp;md5=01e5816a7835457288759531f3305806" title="Flattr" target="_blank"><img src="http://emanuelduss.ch/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://emanuelduss.ch/2011/01/fotos-automatisch-drehen-mit-jhead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://emanuelduss.ch/?flattrss_redirect&amp;id=75&amp;md5=01e5816a7835457288759531f3305806" type="text/html" />
	</item>
		<item>
		<title>Screenshots erstellen mit scrot</title>
		<link>http://emanuelduss.ch/2011/01/screenshots-erstellen-mit-scrot/</link>
		<comments>http://emanuelduss.ch/2011/01/screenshots-erstellen-mit-scrot/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 13:04:54 +0000</pubDate>
		<dc:creator>Emanuel Duss</dc:creator>
				<category><![CDATA[Skripts]]></category>
		<category><![CDATA[konsole]]></category>
		<category><![CDATA[screenshot]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[scrot]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://emanuelduss.ch/?p=82</guid>
		<description><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2011/01/screenshots-erstellen-mit-scrot/&amp;text=Screenshots erstellen mit scrot&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
Es gibt viele Wege, wie man einen Screenshot erstellen kann. Für diese Aufgabe verwende ich scrot. Wenn ich vom ganzen Desktop einen Screenshot machen will, starte ich scrot direkt aus der Shell: emanuel@discordia:~ $ scrot screenshot.png Nach dem Ausführen von diesem Befehl befindet sich der Screenshot mit dem Dateinamen screenshot.png im aktuellen Verzeichnis. Oft will [...]]]></description>
			<content:encoded><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2011/01/screenshots-erstellen-mit-scrot/&amp;text=Screenshots erstellen mit scrot&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
<p>Es gibt viele Wege, wie man einen Screenshot erstellen kann. Für diese Aufgabe verwende ich <em>scrot</em>.<br />
<span id="more-82"></span><br />
Wenn ich vom ganzen Desktop einen Screenshot machen will, starte ich <em>scrot</em> direkt aus der Shell:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel<span style="color: #000000; font-weight: bold;">@</span>discordia:~<br />
$ scrot screenshot.png</div></div>
<p>Nach dem Ausführen von diesem Befehl befindet sich der Screenshot mit dem Dateinamen <em>screenshot.png</em> im aktuellen Verzeichnis.</p>
<p>Oft will ich mit einem Screenshot nur einen Ausschnitt von meinem Desktop dokumentieren. Für diesen Zweck kann man folgenden Befehl in der Shell ausführen:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@discordia:~<br />
$ scrot -s screenshot.png</div></div>
<p>Nach dem Ausführen von diesem Befehl kann man mit der Maus einen Bereich auf dem Desktop markieren. Der ausgewählte Bereich wird in der Datei <em>screenshot.png</em> gespeichert.</p>
<p>Um das ganze zu automatisieren und noch etwas praktischer zu machen, habe ich mir folgendes Skript geschrieben:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
<span style="color: #666666; font-style: italic;">########################################################################</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># screenshot</span><br />
<span style="color: #666666; font-style: italic;"># Erstellt Screenshots</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># Copyright 2011 Emanuel Duss</span><br />
<span style="color: #666666; font-style: italic;"># Licensed under GNU General Public License</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># 2009-12-07; Emanuel Duss; Erstellt und erste Version</span><br />
<span style="color: #666666; font-style: italic;"># 2010-08-22; Emanuel Duss; Mirage statt eog als Viewer</span><br />
<span style="color: #666666; font-style: italic;"># 2011-01-01; Emanuel Duss; Feh statt Mirage als Viewer</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;">########################################################################</span><br />
<br />
<span style="color: #666666; font-style: italic;">########################################################################</span><br />
<span style="color: #666666; font-style: italic;"># Variabeln</span><br />
<span style="color: #007800;">FOLDER</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HOME</span>/Daten/Screenshots&quot;</span><br />
<span style="color: #007800;">APP</span>=<span style="color: #ff0000;">&quot;feh --borderless --scale-down --image-bg black&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;">########################################################################</span><br />
<span style="color: #666666; font-style: italic;"># Main</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$FOLDER</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$FOLDER</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; scrot <span style="color: #660033;">-s</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$APP</span> <span style="color: #000099; font-weight: bold;">\$</span>f&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$FOLDER</span>/%Y-%m-%d_%k-%M-%S.png&quot;</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #666666; font-style: italic;"># EOF</span></div></div>
<p>Nach dem Starten vom Skript muss man einen Bereich auf dem Desktop markieren. Der Screenshot wird in meinem Screenshot-Verzeichnis mit einem passenden Namen (Datum und Uhrzeit) abgespeichert und dann direkt mit meinem Bildanzeiger geöffnet.</p>
 <p><a href="http://emanuelduss.ch/?flattrss_redirect&amp;id=82&amp;md5=e22a2e64b4ae11adfa93c2fdf7506283" title="Flattr" target="_blank"><img src="http://emanuelduss.ch/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://emanuelduss.ch/2011/01/screenshots-erstellen-mit-scrot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://emanuelduss.ch/?flattrss_redirect&amp;id=82&amp;md5=e22a2e64b4ae11adfa93c2fdf7506283" type="text/html" />
	</item>
		<item>
		<title>Bilder verkleinern mit convert (imagemagick)</title>
		<link>http://emanuelduss.ch/2010/12/bilder-verkleinern-mit-convert-imagemagick/</link>
		<comments>http://emanuelduss.ch/2010/12/bilder-verkleinern-mit-convert-imagemagick/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 16:55:04 +0000</pubDate>
		<dc:creator>Emanuel Duss</dc:creator>
				<category><![CDATA[Multimedia]]></category>
		<category><![CDATA[Skripts]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[fotos]]></category>
		<category><![CDATA[konsole]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://emanuelduss.ch/?p=98</guid>
		<description><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2010/12/bilder-verkleinern-mit-convert-imagemagick/&amp;text=Bilder verkleinern mit convert (imagemagick)&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
Wenn man im Internet eine Fotogalerie publizeren will, oder man viele Fotos per E-Mail verschicken will, sollte man die Fotos verkleinern. Ich habe mir ein Skript geschrieben, welches die Auflösung der Bilder verkleinert und die JPEG-Qualitätsstufe heruntersetzt. Somit kann man ganz schnell viele Bilder verkleinern. Mit dem Befehl convert kann ein Bild verkleinert werden. Hierzu [...]]]></description>
			<content:encoded><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2010/12/bilder-verkleinern-mit-convert-imagemagick/&amp;text=Bilder verkleinern mit convert (imagemagick)&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
<p>Wenn man im Internet eine Fotogalerie publizeren will, oder man viele Fotos per E-Mail verschicken will, sollte man die Fotos verkleinern. Ich habe mir ein Skript geschrieben, welches die Auflösung der Bilder verkleinert und die JPEG-Qualitätsstufe heruntersetzt. Somit kann man ganz schnell viele Bilder verkleinern.<br />
<span id="more-98"></span><br />
Mit dem Befehl <em>convert</em> kann ein Bild verkleinert werden. Hierzu muss das Paket <em>imagemagick</em> installiert sein.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">convert -resize 2048x2048 -quality 60 bild.jpg klein.jpg</div></div>
<p>Man sieht gut, wie sich die Dateigrösse verändert:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@discordia:/tmp<br />
$ du -h bild.jpg klein.jpg <br />
1.5M &nbsp; &nbsp;bild.jpg<br />
168K &nbsp; &nbsp;klein.jpg</div></div>
<p>Die Datei wurde durch diesen Vorgang um 90% kleiner.</p>
<p>Um mehrere Bilder in einem Verzeichnis zu verkleinern, habe ich mir ein Skript geschrieben. Dieses Skript erstellt den Unterordner <em>small</em>, verkleinert alle Bilder und gibt aus, wie viele Fotos bereits verkleinert wurden.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
<span style="color: #666666; font-style: italic;">########################################################################</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># imageshrink</span><br />
<span style="color: #666666; font-style: italic;"># Verkleinert alle Bilder im aktuellen Verzeichnis</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># Copyright 2010 Emanuel Duss</span><br />
<span style="color: #666666; font-style: italic;"># Licensed under GNU General Public License</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># 2009-10-09; Emanuel Duss; Erste Version</span><br />
<span style="color: #666666; font-style: italic;"># 2010-12-12; Emanuel Duss; Optionen als Variabeln</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;">########################################################################</span><br />
<br />
<span style="color: #666666; font-style: italic;">########################################################################</span><br />
<span style="color: #666666; font-style: italic;"># Variabeln</span><br />
<span style="color: #007800;">COUNT</span>=<span style="color: #000000;">0</span><br />
<span style="color: #007800;">TOTAL</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">*</span>.<span style="color: #7a0874; font-weight: bold;">&#91;</span>Jj<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>Pp<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>Gg<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -w<span style="color: #000000; font-weight: bold;">`</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Optionen</span><br />
<span style="color: #007800;">FOLDER</span>=<span style="color: #ff0000;">&quot;small&quot;</span><br />
<span style="color: #007800;">SIZE</span>=<span style="color: #ff0000;">&quot;2048x2048&quot;</span><br />
<span style="color: #007800;">QUALITY</span>=<span style="color: #ff0000;">&quot;60&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;">########################################################################</span><br />
<span style="color: #666666; font-style: italic;"># Main</span><br />
<br />
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$FOLDER</span><br />
<br />
<span style="color: #000000; font-weight: bold;">for</span> datei <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span>.<span style="color: #7a0874; font-weight: bold;">&#91;</span>Jj<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>Pp<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>Gg<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; <span style="color: #007800;">COUNT</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$COUNT</span> + <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$datei</span>: Foto <span style="color: #007800;">$COUNT</span> von <span style="color: #007800;">$TOTAL</span> \<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #000000;">100</span> \<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #007800;">$COUNT</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #007800;">$TOTAL</span><span style="color: #000000; font-weight: bold;">`%</span>\<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; convert <span style="color: #660033;">-resize</span> <span style="color: #007800;">$SIZE</span> <span style="color: #660033;">-quality</span> <span style="color: #007800;">$QUALITY</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$datei</span>&quot;</span> <span style="color: #ff0000;">&quot;small/<span style="color: #007800;">$datei</span>&quot;</span> <br />
<span style="color: #000000; font-weight: bold;">done</span><br />
<br />
<span style="color: #666666; font-style: italic;"># EOF</span></div></div>
<p>Die Auflösung und die JPEG-Qualitätsstufe kann in den Variabeln angepasst werden.</p>
 <p><a href="http://emanuelduss.ch/?flattrss_redirect&amp;id=98&amp;md5=af01304fa287f3a01be6bfa2a241d331" title="Flattr" target="_blank"><img src="http://emanuelduss.ch/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://emanuelduss.ch/2010/12/bilder-verkleinern-mit-convert-imagemagick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://emanuelduss.ch/?flattrss_redirect&amp;id=98&amp;md5=af01304fa287f3a01be6bfa2a241d331" type="text/html" />
	</item>
		<item>
		<title>Ein Backup-Konzept mit Hardlinks und rsync</title>
		<link>http://emanuelduss.ch/2010/11/ein-backup-konzept-mit-hardlinks-und-rsync/</link>
		<comments>http://emanuelduss.ch/2010/11/ein-backup-konzept-mit-hardlinks-und-rsync/#comments</comments>
		<pubDate>Wed, 24 Nov 2010 22:54:31 +0000</pubDate>
		<dc:creator>Emanuel Duss</dc:creator>
				<category><![CDATA[Skripts]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[konsole]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://emanuelduss.ch/?p=80</guid>
		<description><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2010/11/ein-backup-konzept-mit-hardlinks-und-rsync/&amp;text=Ein Backup-Konzept mit Hardlinks und rsync&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
Da es für mich keine passende Backup-Lösung gab, habe ich mir diese selber geschrieben. Meine Daten werden jetzt per rsync auf meinen Backup-Server synchronisiert. Für meine Backup-Lösung braucht man nicht zwingend einen Backup-Server. Mit rsync kann man auch auf dem lokalen Rechner Dateien und Verzeichnisse synchronisieren. Das tolle an meinem Skript ist, dass ich verschiedene [...]]]></description>
			<content:encoded><![CDATA[
<div class="twitterbutton" style="float: right; padding-left: 5px;"><a href="http://twitter.com/share?url=http://emanuelduss.ch/2010/11/ein-backup-konzept-mit-hardlinks-und-rsync/&amp;text=Ein Backup-Konzept mit Hardlinks und rsync&amp;via=mindfuckup&amp;related=DolcePixel"><img align="right" src="http://emanuelduss.ch/wp-content/plugins//easy-twitter-button/i/buttons/en/tweetn.png" style="border: none;" alt="" /></a></div>
<p>Da es für mich keine passende Backup-Lösung gab, habe ich mir diese selber geschrieben. Meine Daten werden jetzt per rsync auf meinen Backup-Server synchronisiert. Für meine Backup-Lösung braucht man nicht zwingend einen Backup-Server. Mit rsync kann man auch auf dem lokalen Rechner Dateien und Verzeichnisse synchronisieren.<br />
<span id="more-80"></span><br />
Das tolle an meinem Skript ist, dass ich verschiedene Versionen von meinen Daten habe. Wenn ich eine Datei lösche und dann mein Backup starte, wird diese Datei auf dem Backup-Server nicht gelöscht! Dies geschieht mit Hardlinks. Das geniale daran ist, dass nur die neuen Daten neuen Platz auf der Harddisk beanspruchen. Obwohl ich über 10 mal die selbe Datei gesichert habe, wird deren Speicherplatz nur einmal belegt.</p>
<p><strong>Voraussetzung</strong></p>
<p>Meine Backuplösung basiert auf diversen Bash-Skripten. Diese müssen mit den nötigen Rechten ausgeführt werden können. Will man die Daten auf einen Server sichern, benötigt man dort ein SSH-Login. Am einfachsten geht dies mit Public-/Private-Keys, damit man nicht jedes mal ein Passwort eingeben muss.<br />
Als Client benutze ich mein Lenovo Thinkpad T61 Notebook und mein Asus EEEPC 1000H Netbook, welche beide mit Arch Linux laufen. Bei meinem Backup-Server handelt es sich um eine Asus EEEBOX, welche mit Debian 5.0 läuft. Das Backup-Skript sollte jedoch auf jedem Linux lauffähig sein.</p>
<p><strong>Übersicht</strong><br />
Hier eine kleine übersicht über mein Backup-Konzept:<br />
<div id="attachment_139" class="wp-caption alignnone" style="width: 310px"><a href="http://emanuelduss.ch/wp-content/uploads/2010/11/backup.png" rel="lightbox[80]"><img src="http://emanuelduss.ch/wp-content/uploads/2010/11/backup-300x254.png" alt="Backup-Konzept" title="backup" width="300" height="254" class="size-medium wp-image-139" /></a><p class="wp-caption-text">Backup-Konzept</p></div></p>
<p><strong>Komponenten</strong></p>
<p>Mein Backup-Script benötigt folgende Komponenten:</p>
<ul>
<li><em>install</em>: Installiert die Verzeichnisstruktur für die Backups auf dem Server/Computer</li>
<li><em>crontab</em>: Die Einträge in der Crontab rufen das Backup-Script auf dem Server auf. Dies kann aber auch manuell gemacht werden.</li>
<li><em>backup</em>: Dieses Skript kopiert die Backup Ordner und ermöglicht so eine Versionierung</li>
<li><em>syncup</em>: Mit diesem Skript werden meine Daten auf den Server synchronisiert</li>
<li><em>syncup.conf</em>: Wird syncup ohne Parameter aufgerufen, werden die in dieser Datei angegebenen Dateien und Verzeichnisse gesichert.</li>
</ul>
<p><strong>Installation</strong></p>
<p>Das Installationsskript <em>install</em> erstellt folgende Ordner:</p>
<ul>
<li><em>backupdata</em>: Hier werden die zu sichernden Daten abgespeichert</li>
<li><em>daily_1</em> bis <em>daily_7</em>: Eine Version der Daten von den letzten sieben Tagen</li>
<li><em>weekly_1</em> bis <em>weekly_4</em>: Eine Version der Daten von den letzten vier Wochen</li>
<li><em>monthly_1</em> bis <em>monthly_12</em>: Eine Version der Daten von den letzten zwölf Monaten</li>
<li><em>yearly_1</em> bis <em>yearly_5</em>: Eine Version der Daten von den letzten fünf Halbjahren</li>
</ul>
<p>Folgendes Skript erstellt mir die Ordnerstruktur:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># install</span><br />
<span style="color: #666666; font-style: italic;"># Erstellt die Verzeichnisse fuer backup</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># Copyright 2010 Emanuel Duss</span><br />
<span style="color: #666666; font-style: italic;"># Licensed under GNU General Public License</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># 2009-12-05; Emanuel Duss; Erste Version</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;"># Main</span><br />
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Ordner fuer die Synchronisation</span><br />
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> backupdata<br />
<br />
<span style="color: #666666; font-style: italic;"># Ordner fuer taegliche Backups</span><br />
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">1</span> <span style="color: #000000;">7</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> daily_<span style="color: #007800;">$i</span><br />
<span style="color: #000000; font-weight: bold;">done</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Ordner fuer woechentliche Backups</span><br />
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">1</span> <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> weekly_<span style="color: #007800;">$i</span><br />
<span style="color: #000000; font-weight: bold;">done</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Ordner fuer monatliche Backups</span><br />
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">1</span> <span style="color: #000000;">12</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> monthly_<span style="color: #007800;">$i</span><br />
<span style="color: #000000; font-weight: bold;">done</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Ordner fuer halbjaehrliche Backups</span><br />
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">1</span> <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> yearly_<span style="color: #007800;">$i</span><br />
<span style="color: #000000; font-weight: bold;">done</span><br />
<br />
<span style="color: #666666; font-style: italic;"># EOF</span></div></div>
<p><strong>Synchronisation</strong></p>
<p>Das Skript <em>syncup</em> synchronisiert die als Parameter angegebene Verzeichnisse und Dateien auf meinen Backup-Server. Werden keine Parameter angegeben, werden die Dateien und Verzeichnisse aus dem Konfigurationsfile <em>syncup.conf</em> gesichert. Will man keinen Backup-Server nutzen, sondern eine lokale Sicherung durchführen (z. B. auf eine externe Festplatte), lässt man bei der Variable <em>BACKUPPATH</em> den Hostnamen weg.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># syncup</span><br />
<span style="color: #666666; font-style: italic;"># Synrchonisiert die Backup-Daten</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># Copyright 2009 Emanuel Duss</span><br />
<span style="color: #666666; font-style: italic;"># Licensed under GNU General Public License</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># 2009-12-07; Emanuel Duss; Erster Entwurf</span><br />
<span style="color: #666666; font-style: italic;"># 2009-12-15; Emanuel Duss; Erste produktive Version</span><br />
<span style="color: #666666; font-style: italic;"># 2010-01-17; Emanuel Duss; rsync --progress</span><br />
<span style="color: #666666; font-style: italic;"># 2010-09-14; Emanuel Duss; $BACKUPSRV, prepare () für mount</span><br />
<span style="color: #666666; font-style: italic;"># 2010-10-06; Emanuel Duss; rycnc -h (Human)</span><br />
<span style="color: #666666; font-style: italic;"># 2010-11-25; Emanuel Duss; Nutze Parameter als Quellverzeichnis</span><br />
<span style="color: #666666; font-style: italic;"># 2010-11-27; Emanuel Duss; Mehrere Verzeichnisse und Konfigfile</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;"># Variabeln</span><br />
<span style="color: #007800;">TIMESTAMP</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`date +%Y-%m-%d_%H-%M-%S`</span>&quot;</span><br />
<span style="color: #007800;">HOSTNAME</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`uname -n`</span>&quot;</span><br />
<br />
<span style="color: #007800;">RSYNC</span>=<span style="color: #ff0000;">&quot;/usr/bin/rsync&quot;</span><br />
<span style="color: #007800;">RSYNC_PARAMETER</span>=<span style="color: #ff0000;">&quot;-avhz --progress --delete&quot;</span><br />
<br />
<span style="color: #007800;">BACKUPSRV</span>=<span style="color: #ff0000;">&quot;emanuel@eeebox&quot;</span><br />
<span style="color: #007800;">BACKUPPATH</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$BACKUPSRV</span>:/media/backup/backup/backupdata/<span style="color: #007800;">$HOSTNAME</span>/&quot;</span><br />
<br />
<span style="color: #007800;">CONFIGFILE</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`dirname $0`</span>/syncup.conf&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;"># Main</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Lege die zu sichernden Files fest</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;$*&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; <span style="color: #007800;">SOURCE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$*</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ gsub(&quot;/ &quot;,&quot; &quot;); gsub(&quot;/$&quot;,&quot;&quot;); print }'</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CONFIGFILE</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Konfigurationsfile: <span style="color: #007800;">$CONFIGFILE</span>&quot;</span><br />
&nbsp; <span style="color: #007800;">SOURCE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-E</span> <span style="color: #ff0000;">&quot;^[^#]&quot;</span> <span style="color: #007800;">$CONFIGFILE</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #ff0000;">&quot; &quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ gsub(&quot;/ &quot;,&quot; &quot;); gsub(&quot;/$&quot;,&quot;&quot;); print }'</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage:&quot;</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;syncup [ Verzeichnisse und Dateien ]&quot;</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Wird kein Parameter angegeben, wird das Konfigfile <span style="color: #007800;">$CONFIGFILE</span> verwendet.&quot;</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Info ausgeben</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Source: <span style="color: #007800;">$SOURCE</span>&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Target: <span style="color: #007800;">$BACKUPPATH</span>&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <br />
<br />
<span style="color: #666666; font-style: italic;"># Backup-HD mounten</span><br />
<span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">$BACKUPSRV</span> <span style="color: #ff0000;">&quot;sudo mount /media/backup&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Dateien synchronisieren</span><br />
<span style="color: #007800;">$RSYNC</span> <span style="color: #007800;">$RSYNC_PARAMETER</span> <span style="color: #007800;">$SOURCE</span> <span style="color: #007800;">$BACKUPPATH</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Backup-HD umounten</span><br />
<span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">$BACKUPSRV</span> <span style="color: #ff0000;">&quot;sudo umount /media/backup&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># EOF</span></div></div>
<p>Entweder wird das Skript direkt mit <em>./syncup</em> im aktuellen Verzeichnis aufgerufen, oder man platziert es in einen Ordner, der in der <em>$PATH</em>-Variable eingetragen ist (z. B. <em>/usr/local/bin</em>). Jetzt kann dieses Skript in der Konsole aufgerufen werden:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@discordia:~<br />
$ sudo syncup Daten/ /etc/ /var/www<br />
Source: /etc<br />
Target: emanuel@eeebox:/media/backup/backup/backupdata/discordia/<br />
<br />
sending incremental file list<br />
etc/openvpn/client.conf<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;880 100% &nbsp;175.78kB/s &nbsp; &nbsp;0:00:00 (xfer#1, to-check=539/1389)<br />
<br />
sent 47.16K bytes &nbsp;received 219 bytes &nbsp;31.59K bytes/sec<br />
total size is 6.02M &nbsp;speedup is 127.00</div></div>
<p>Ich muss das Skript mit den nötigen Rechten aufrufen. Das Verzeichnis /etc ist nur durch den User root vollständig lesbar. Deshalb rief ich das Skript mit sudo auf. Für eigene Verzeichnisse ist dies nicht nötig.<br />
Die Daten befinden sich jetzt im Ordner <em>backupdata</em> auf dem Backup-Server.</p>
<p>Das File <em>syncup.conf</em> sieht folgendermassen aus:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># syncup.conf</span><br />
<span style="color: #666666; font-style: italic;"># Konfigurationsdatei fuer syncup</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># Copyright 2010 Emanuel Duss</span><br />
<span style="color: #666666; font-style: italic;"># Licensed under GNU General Public License</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># 2010-11-27; Emanuel Duss; Erste Version</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Verzeichnisse</span><br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>Daten<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.config<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.filezilla<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.ssh<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.vim<br />
<br />
<span style="color: #666666; font-style: italic;"># Files</span><br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.conkyrc<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.bashrc<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.exrc<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.fehrc<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.history<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.muttrc<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.screenrc<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.vimrc<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.vimperatorrc<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.xinitrc<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.Xdefaults<br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>emanuel<span style="color: #000000; font-weight: bold;">/</span>.smbcredentials<span style="color: #000000; font-weight: bold;">*</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Systemdaten</span><br />
<span style="color: #000000; font-weight: bold;">/</span>etc<br />
<br />
<span style="color: #666666; font-style: italic;">#EOF</span></div></div>
<p>Wenn syncup ohne Parameter aufgerufen wird, werden alle Dateien und Verzeichnisse aus diesem Konfigurationsfile gesichert:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@discordia:~<br />
$ sudo syncup<br />
Konfigurationsfile: /home/emanuel/Daten/Scripts/syncup.conf<br />
<br />
Source: /home/emanuel/Daten /home/emanuel/.config /home/emanuel/.filezilla<br />
/home/emanuel/.ssh /home/emanuel/.vim /home/emanuel/.conkyrc /home/emanuel/.bashrc<br />
/home/emanuel/.exrc /home/emanuel/.fehrc /home/emanuel/.history /home/emanuel/.muttrc<br />
/home/emanuel/.screenrc /home/emanuel/.vimrc /home/emanuel/.vimperatorrc<br />
/home/emanuel/.xinitrc /home/emanuel/.Xdefaults /home/emanuel/.smbcredentials* /etc <br />
Target: emanuel@eeebox:/media/backup/backup/backupdata/discordia/<br />
<br />
sending incremental file list<br />
etc/openvpn/up.sh<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;453 100% &nbsp; &nbsp;0.00kB/s &nbsp; &nbsp;0:00:00 (xfer#1, to-check=540/393538)<br />
<br />
sent 6.34M bytes &nbsp;received 32.75K bytes &nbsp;296.59K bytes/sec<br />
total size is 73.20G &nbsp;speedup is 11479.75</div></div>
<p><strong>Backup</strong><br />
Die Daten wurden erst auf den Server synchronisiert. Wenn man eine Datei auf der Workstation löschen würde, dann wäre diese bei der nächsten Synchronisation ebenfalls gelöscht. Darum erstelle ich pro Tag, Woche, Monat und Halbjahr eine Kopie aller Daten. Dies erledigt mein Backup-Server. Da ich hierfür Hardlinks verwende, wird bei jeder Kopie kein weiterer Speicherplatz beansprucht. Lediglich neue Daten beanspruchen neuen Speicherplatz. Das ist genial!</p>
<p>Das Backup-Skript sieht folgendermassen aus:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># backup</span><br />
<span style="color: #666666; font-style: italic;"># Backup mit Hardlinks</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># Copyright 2009 Emanuel Duss</span><br />
<span style="color: #666666; font-style: italic;"># Licensed under GNU General Public License</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># 2009-10-22; Emanuel Duss; Erster Entwurf</span><br />
<span style="color: #666666; font-style: italic;"># 2009-12-05; Emanuel Duss; Erste produktive Version</span><br />
<span style="color: #666666; font-style: italic;"># 2010-04-27; Emanuel Duss; Logfile in /var/log</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;"># Variabeln</span><br />
<span style="color: #007800;">BACKUPDIR</span>=<span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>backup<span style="color: #000000; font-weight: bold;">/</span>backup<br />
<span style="color: #007800;">LOGFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>backup.log<br />
<span style="color: #007800;">TIMESTAMP</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y-<span style="color: #000000; font-weight: bold;">%</span>m-<span style="color: #000000; font-weight: bold;">%</span>d_<span style="color: #000000; font-weight: bold;">%</span>H-<span style="color: #000000; font-weight: bold;">%</span>M-<span style="color: #000000; font-weight: bold;">%</span>S<span style="color: #000000; font-weight: bold;">`</span><br />
<br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;"># Funktionen</span><br />
usage <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage:<br />
&nbsp; &nbsp; &nbsp; &nbsp; backup ( daily | weekly | monthly | yearly )&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;"># Backup-Funktionen</span><br />
daily <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-r</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_7<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_6 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_7<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_5 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_6<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_4 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_5<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_3 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_4<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_2 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_3<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_1 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_2<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_1<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-al</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>backupdata<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>daily_1<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
weekly <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-r</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>weekly_4<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>weekly_3 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>weekly_4<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>weekly_2 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>weekly_3<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>weekly_1 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>weekly_2<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>weekly_1<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-al</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>backupdata<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>weekly_1<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
monthly <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-r</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_12<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_11 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_12<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_10 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_11<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_9 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_10<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_8 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_9<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_7 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_8<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_6 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_7<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_5 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_6<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_4 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_5<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_3 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_4<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_2 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_3<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_1 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_2<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_1<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-al</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>backupdata<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>monthly_1<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
yearly <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-r</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>yearly_5<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>yearly_4 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>yearly_5<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>yearly_3 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>yearly_4<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>yearly_2 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>yearly_3<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>yearly_1 <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>yearly_2<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>yearly_1<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-al</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>backupdata<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #007800;">$BACKUPDIR</span><span style="color: #000000; font-weight: bold;">/</span>yearly_1<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">################################################################</span><br />
<span style="color: #666666; font-style: italic;"># Main</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TIMESTAMP</span> Backup $1 start&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">in</span><br />
&nbsp; daily<span style="color: #000000; font-weight: bold;">|</span>weekly<span style="color: #000000; font-weight: bold;">|</span>monthly<span style="color: #000000; font-weight: bold;">|</span>yearly<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>backup<br />
&nbsp; &nbsp; <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #000000; font-weight: bold;">/</span>media<span style="color: #000000; font-weight: bold;">/</span>backup<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; usage<br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span><br />
<span style="color: #000000; font-weight: bold;">esac</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TIMESTAMP</span> Backup $1 done&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span><br />
<br />
<span style="color: #666666; font-style: italic;"># EOF</span></div></div>
<p>Kurze Erklärung: Der älteste Ordner wird gelöscht. Dann werden alle um eins verschoben. Das Herzstück vom ganzen Backup verbirgt sich hinter der Option <em>-l</em> von <em>cp</em>. Diese Option erstellt lediglich einen Hardlink von allen Dateien. Dies ist das tolle daran. Bei der Kopie mit <em>cp -al src dst</em> wird kein weiterer Speicherplatz auf dem Speichermedium belegt!</p>
<p><strong>Backups erstellen</strong><br />
In der Crontab, welche mit <em>sudo crontab -e</em> aufgerufen wird, erstelle ich folgende Einträge:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># Backup<br />
# Backup daily; 1:30h<br />
30 1 &nbsp; * &nbsp; * &nbsp; * &nbsp; &nbsp; &nbsp; /usr/local/bin/backup daily<br />
# Backup weekly; Montag, 2:00h<br />
0 &nbsp;2 &nbsp; * &nbsp; * &nbsp; 1 &nbsp; &nbsp; &nbsp; /usr/local/bin/backup weekly<br />
# Backup monthly; 1. Tag 4:00h<br />
0 &nbsp;4 &nbsp; 1 &nbsp; * &nbsp; * &nbsp; &nbsp; &nbsp; /usr/local/bin/backup monthly<br />
# Backup yearly; 31. Dezember 3:00h<br />
0 &nbsp;3 &nbsp;31 &nbsp;12 &nbsp; * &nbsp; &nbsp; &nbsp; /usr/local/bin/backup yearly</div></div>
<p>Jetzt werden zu bestimmten Zeiten die vberschiedenen Backups durchgeführt. Natürlich kann man die Befehle auch von Hand ausführen. Jedoch vereinfachen die Cronjobs diese Aufgabe erheblich!</p>
<p><strong>Überwachung</strong><br />
Im Logfile können wir uns über den Status informieren:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@eeebox:~<br />
$ tail /var/log/backup.log<br />
2010-11-25_23-31-55 Backup daily start<br />
2010-11-25_23-31-55 Backup daily done</div></div>
<p>Ich sehe keine Fehlermeldung. Das Backup hat funktioniert!</p>
<p><strong>Restore</strong><br />
Ein Backup ist ohne erfolgreichen Restore gar nichts wert! Das restoren ist sehr einfach. Man kann einfach den gewünschten Ordner oder die gewünschte Datei zurückkopieren. Man muss gar nichts beachten!</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">emanuel@eeebox:/media/backup/backup/weekly_2/discordia<br />
$ scp -r Daten/ discordia:/tmp/</div></div>
<p><strong>Download</strong><br />
Hier könnt ihr alle Dateien als Archiv herunterladen: <a href='http://emanuelduss.ch/wp-content/uploads/2010/11/backup_emanuelduss.tar.gz'>backup_emanuelduss.tar</a></p>
<p><strong>Schluss</strong><br />
Wenn man das Backup einmal eingerichtet hat, hat man eine sehr zuverlässige Lösung um seine Daten zu sichern. Ich rate jedem an, seine Daten regelmässig zu sichern und auch den Restore durchzuspielen! Das Logfile sollte regelmässig nach Fehlern durchsucht werden, um die integrität aller Backup-Daten festzustellen.</p>
<p>Für Anmerkungen, Kritik und Verbesserungsvorschläge bin ich jederzeit dankbar und offen! Man lernt schliesslich nie aus!</p>
<p>Viel Spass mit euren Backups.</p>
 <p><a href="http://emanuelduss.ch/?flattrss_redirect&amp;id=80&amp;md5=6d518e8d2a420feb17c3931b3f728eac" title="Flattr" target="_blank"><img src="http://emanuelduss.ch/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://emanuelduss.ch/2010/11/ein-backup-konzept-mit-hardlinks-und-rsync/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<atom:link rel="payment" href="http://emanuelduss.ch/?flattrss_redirect&amp;id=80&amp;md5=6d518e8d2a420feb17c3931b3f728eac" type="text/html" />
	</item>
	</channel>
</rss>

