<?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>monkey-business.biz &#187; Administration</title> <atom:link href="http://www.monkey-business.biz/tag/administration/feed/" rel="self" type="application/rss+xml" /><link>http://www.monkey-business.biz</link> <description>Belästigung der Allgemeinheit - der private Weblog</description> <lastBuildDate>Tue, 24 Jan 2012 14:53:33 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>daily</sy:updatePeriod> <sy:updateFrequency>4</sy:updateFrequency> <item><title>Von Hetzner SysCP Image zu Froxlor</title><link>http://www.monkey-business.biz/1474/von-hetzner-syscp-image-zu-froxlor/</link> <comments>http://www.monkey-business.biz/1474/von-hetzner-syscp-image-zu-froxlor/#comments</comments> <pubDate>Wed, 16 Feb 2011 02:23:38 +0000</pubDate> <dc:creator>Loaden</dc:creator> <category><![CDATA[Belästigung der Allgemeinheit - mein privater Weblog]]></category> <category><![CDATA[Administration]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Froxlor]]></category> <category><![CDATA[Hetzner]]></category> <category><![CDATA[Hosting]]></category> <category><![CDATA[SysCP]]></category> <category><![CDATA[Tutorial]]></category><guid isPermaLink="false">http://www.monkey-business.biz/?p=1474</guid> <description><![CDATA[Ich möchte vorweg darauf hinweisen, das es bei mir bei dem Update heute nacht um 3 Uhr etwas turbulent zur Sache ging. Keine der Anleitungen die ich online gefunden hatte hatten ihr Froxlor Installationen nach dem Upgrade von SysCP überprüft. Keine dieser Anleitungen verlief Fehlerlos bzw. ohne Folgefehler durch Konfigurationsfehler. Der Server sollte natürlich bis [...]]]></description> <content:encoded><![CDATA[<p>Ich möchte vorweg darauf hinweisen, das es bei mir bei dem Update heute nacht um 3 Uhr etwas turbulent zur Sache ging. Keine der Anleitungen die ich online gefunden hatte hatten ihr Froxlor Installationen nach dem Upgrade von SysCP überprüft. Keine dieser Anleitungen verlief Fehlerlos bzw. ohne Folgefehler durch Konfigurationsfehler. Der Server sollte natürlich bis morgens wieder für Hosting Kunden nutzbar funktionieren. Ich hoffe dieser Ärger bleibt euch mit diesem Tutorial erspart.</p><h3>Vorwort</h3><ul><li>Es wird eine funktionsfähige Hetzner SysCP Image Installtion benötigt (SysCP Root: /var/syscp/web/)</li><li>Der gesamte Installationsvorgang findet über eine SSH Verbindung auf dem Server statt</li><li>Allgemein gilt in diesem Tutorial <NAME> immer durch die entsprechenden Werte zu ersetzen</li></ul><h3>Update Vorbereitungen</h3><ul><li> <strong>SysCP sichern</strong><br /> Zunächst sollten alle Daten von SysCP gesichert werden. Ebenso machen wir ein Backup von /etc/ da wir hier im zuge des Upgrades auch Änderungen vornehmen werden. Wir nutzen für das SysCP Datenbank Backup die Option &#8220;&#8211;add-drop-table&#8221; um ein löschen der alten Inhalte vor dem einspielen der neuen auszulösen. Diese Option benötigen wir da wir im zuge des Updates den veränderten SysCP SQL Dump in diese selbe Datenbank wieder einspielen. Eure MySQL Zugangsdaten findet ihr in der SysCP Konfiguration (/var/syscp/lib/userdata.inc.php /).</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># cp -rp /etc/ /root/etc_bak/</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># cd /var/syscp/web/</span>
EMP-S:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>syscp<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span><span style="color: #666666; font-style: italic;"># cp -rp * ../../syscp_bak/</span>
EMP-S:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>syscp<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span><span style="color: #666666; font-style: italic;"># mysqldump --databases --opt -Q -u&lt;USERNAME&gt; -p&lt;PASSWORT&gt; --add-drop-table syscp &gt; ../../syscp_bak/db.sql</span></pre></div></div></li><li> <strong>sources.list erweitern</strong></li><p>Die Datei /etc/apt/sources.list um erweitern um:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">deb      http:<span style="color: #000000; font-weight: bold;">//</span>debian.froxlor.org lenny main
deb-src  http:<span style="color: #000000; font-weight: bold;">//</span>debian.froxlor.org lenny main</pre></div></div><p>Kommando zum öffnen der Datei (erspart Tipparbeit):</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># nano /etc/apt/sources.list</span></pre></div></div></li><li> <strong>SysCP Cronjobs deaktivieren</strong><br /> Durch auskommentieren der Konfiguration deaktivieren wir die SysCP Cronjobs.<br /> Kommando zum öffnen der Datei:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># nano /etc/cron.d/syscp</span></pre></div></div><p>Dateinhalt nach der Bearbeitung:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Set PATH, otherwise restart-scripts won't find start-stop-daemon</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Regular cron jobs for the syscp package</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#00 */1 * * *   root    /usr/bin/php5 -q /var/syscp/web/scripts/cron_tasks.php</span>
<span style="color: #666666; font-style: italic;">#0 0 * * *      root    /usr/bin/php5 -q /var/syscp/web/scripts/cron_traffic.php</span>
<span style="color: #666666; font-style: italic;">#30 0 * * *     root    /usr/bin/php5 -q /var/syscp/web/scripts/cron_ticketarchive.php</span>
<span style="color: #666666; font-style: italic;">#0 1 * * *      root    /usr/bin/php5 -q /var/syscp/web/scripts/cron_used_tickets_reset.php</span>
<span style="color: #666666; font-style: italic;">#00 */1 * * *   root    /usr/bin/php5 -q /var/syscp/web/scripts/cron_autoresponder.php</span>
<span style="color: #666666; font-style: italic;">#00 */1 * * *   root    /usr/bin/php5 -q /var/syscp/web/scripts/cron_apsinstaller.php</span>
<span style="color: #666666; font-style: italic;">#*/15 * * * *   root    /usr/bin/php5 -q /var/syscp/web/scripts/cron_apsupdater.php</span></pre></div></div></li><li> <strong>SQL Dump für Froxlor aufbereiten</strong><br /> Hierbei ersetzen wir den Pfad /var/syscp/web/ mit /var/www/froxlor/ und den Pfad /var/syscp/ mit /var/www/ in einer Kopie unseren SysCP SQL Dumps.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># cd /var/sycp_bak/</span>
EMP-S:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>sycp_bak<span style="color: #000000; font-weight: bold;">/</span><span style="color: #666666; font-style: italic;"># cp db.sql db_new.sql</span>
EMP-S:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>sycp_bak<span style="color: #000000; font-weight: bold;">/</span><span style="color: #666666; font-style: italic;"># sed -i 's/\/var\/syscp\/web\//\/var\/www\/froxlor\//g' db_new.sql</span>
EMP-S:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>sycp_bak<span style="color: #000000; font-weight: bold;">/</span><span style="color: #666666; font-style: italic;"># sed -i 's/\/var\/syscp\//\/var\/www\//g' db_new.sql</span></pre></div></div></li></ul><h3>Froxlor Installieren</h3><ul><li> <strong>Froxlor Installation über APT Paketmanagement System</strong></p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># apt-get update</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># apt-get install froxlor</span></pre></div></div></li><li> <strong>Besitzer und Gruppe des Froxlor Verzeichnisses anpassen</strong></p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># chown -R www-data:www-data /var/www/froxlor/</span></pre></div></div></li><li> <strong>Alte SysCP Konfiguration in Froxlor nutzen</strong></p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># cp /var/syscp_bak/lib/userdata.inc.php /var/www/froxlor/lib/</span></pre></div></div></li><li> <strong>Bearbeitete Kopie der SysCP Datenbank für Froxlor einspielen</strong></p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># mysql -u&lt;USERNAME&gt; -p&lt;PASSWORT&gt;</span>
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> use syscp  
mysql<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>syscp_bak<span style="color: #000000; font-weight: bold;">/</span>db_new.sql</pre></div></div></li><li> <strong>Symlinks für phpMyAdmin und Squirrelmail erstellen</strong></p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># ln -s /usr/share/squirrelmail/ /var/www/squirrelmail</span></pre></div></div></li><li> <strong>Verzeichnisse kopieren</strong><br /> Wichtig ist hierbei Rechte und Benutzer beizubehalten. Die User Unterverzeichnise in fcgi/ logs/, tmp/ und webs/ sollten den entsprechenden fcgi Benutzer (Kunden) gehören. Das Verzeichnis mails/ dem Benuter vmail.  Das bewirkt die Option -p beim Kopieren mit cp.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># cp -rp /var/syscp/fcgi/ /var/www/</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># cp -rp /var/syscp/logs/ /var/www/</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># cp -rp /var/syscp/mails/ /var/www/</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># cp -rp /var/syscp/tmp/ /var/www/</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># cp -rp /var/syscp/webs/ /var/www/</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># cp -rp /var/syscp/squirrelmail/ /var/www/</span></pre></div></div></li><li> <strong>Apache Konfiguration für Froxlor anpassen</strong><br /> Hierbei muss der Pfad /var/syscp/web/ in /var/www/froxlor geändert werden. Der Ordnung halber ist es empfehlenswert die Konfigurationsdatei entsprechend umzubenennen und den Symbolischen Link auf die Konfiguration zu ändern.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># sed -i 's/\/var\/syscp\/web\//\/var\/www\/froxlor\//g' /etc/apache2/sites-available/syscp</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># mv /etc/apache2/sites-available/syscp /etc/apache2/sites-available/froxlor</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># rm /etc/apache2/sites-enabled/00-syscp</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># ln -s /etc/apache2/sites-available/froxlor /etc/apache2/sites-enabled/froxlor</span></pre></div></div></li><li> <strong>Suexec Pfade für Froxlor anpassen</strong><br /> In der Datei /etc/apache2/suexec/www-data den Pfad /var/syscp/ in /var/www/ ändern.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># sed -i 's/\/var\/syscp\//\/var\/www\//g' /etc/apache2/suexec/www-data</span></pre></div></div></li><li> <strong>Postfix Konfiguration für Froxlor anpassen</strong><br /> Konfigurations Option virtual_mailbox_base in /etc/postfix/main.cf von /var/syscp/mails/ in /var/www/mails/ ändern.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># sed -i 's/\/var\/syscp\/mails\//\/var\/www\/mails\//g' /etc/postfix/main.cf</span></pre></div></div></li><li> <strong>Squirrelmail Konfiguration für Froxlor anpassen</strong><br /> Die Pfade /var/syscp/squirrelmail/data/ und /var/syscp/squirrelmail/attach/ müssen in der Datei auf /var/www/squirrelmail/*/ angepasst werden.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># sed -i 's/\/var\/syscp\//\/var\/www\//g' /etc/squirrelmail/config.php</span></pre></div></div><p><strong>Anmerkung</strong><br /> In dieser Datei können Providername, Logo und dergleichen für Squirrelmail angepasst werden. Nutzt die Gelegenheit sonst macht ihr das nie.</li><li> <strong>Froxlor Cronjob erstellen</strong><br /> Wir erstellen die Datei /etc/cron.d/froxlor</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># nano /etc/cron.d/froxlor</span></pre></div></div><p>und füllen sie mit den Werten für die Froxlor Cronjobs:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Set PATH, otherwise restart-scripts won't find start-stop-daemon</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Regular cron jobs for the froxlor package</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">*/</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>     root    <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php5 <span style="color: #660033;">-q</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>froxlor<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>froxlor_master_cronjob.php</pre></div></div></li><p><strong>Apache und Postfix neu starten</strong></p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># /etc/init.d/apache2 restart</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># /etc/init.d/postfix restart</span></pre></div></div></ul><h3>Froxlor Konfiguration</h3><p>Froxlor ist nun unter Eurer IP:Euerm Port (Standard 81)  erreichbar.</p><ul><li><strong>Installationsassistent</strong><br /> Ich empfehle Froxlor nicht als fcgi auszuführen. Google sagte mir das es dabei Probleme geben soll. Den neuen Prozess Spawn Manager habe ich auch nicht aktiviert. Ich warte erstmal ein paar Erfahrungsberichte ab.</li><li> <strong>Fehlerquelle: php.ini Settings</strong><br /> Die Zeile</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">open_basedir = <span style="color: #ff0000;">&quot;{OPEN_BASEDIR}&quot;</span></pre></div></div><p>sollte in den php.ini Konfigurationen durch</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#123;</span>OPEN_BASEDIR_C<span style="color: #7a0874; font-weight: bold;">&#125;</span>open_basedir = <span style="color: #ff0000;">&quot;{OPEN_BASEDIR}&quot;</span></pre></div></div><p>ersetzt werden. Ansonsten könnte es zu Fehlern in PHP Applikationen kommen. Im Falle Magento bekommt man die Ausgabe &#8220;No input file specified&#8221;.</li></ul><h3>SysCP entfernen</h3><p><strong>Prüft nochmals alle Funktionen bevor ihr euer SysCP vom Server entfernt.</strong></p><ul><li> <strong>SysCP löschen</strong><br /> Das &#8220;immutable&#8221; Attribut von den fcgi Scripts entfernen (chattr -i) und den SysCP Ordner vom Dateisystem löschen.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">EMP-S:~<span style="color: #666666; font-style: italic;"># chattr -i -R /var/syscp/fcgi/</span>
EMP-S:~<span style="color: #666666; font-style: italic;"># rm -r /var/syscp/</span></pre></div></div><p><strong>Vergesst die Backups nicht.</strong> /root/etc_bak/ und /var/syscp_bak/. Aufheben oder löschen. Wie es euch lieb ist.</li><li><strong>Jagd nach Überlebenden</strong><br /> Wer lustig ist kann nun noch nach überbleibseln von SysCP auf dem Server suchen und diese beseitigen. Den Datenbankname könnte man noch von syscp auf froxlor ändern. Ebenso den Unix Benutzer syscp. Weitere Überbleibsel findet man auch mit dem Kommando:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-r</span> syscp <span style="color: #000000; font-weight: bold;">*</span></pre></div></div></li></ul><p>Froxlor ist nun via Debian APT Paketmangement Software updatebar installiert und konfiguriert. Ich hoffe bei euch läuft das mit Hilfe der Anleitung weniger turbulent und stressig. Abweichung und weitere Tipps sind erwünscht. Möchte jemand das Tutorial zu einem Update Script zusammenfassen? <img src='http://www.monkey-business.biz/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://www.monkey-business.biz/1474/von-hetzner-syscp-image-zu-froxlor/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Linux: Prozesse beenden / kill processes</title><link>http://www.monkey-business.biz/1166/linux-prozesse-beenden-kill-processes/</link> <comments>http://www.monkey-business.biz/1166/linux-prozesse-beenden-kill-processes/#comments</comments> <pubDate>Fri, 19 Nov 2010 13:08:25 +0000</pubDate> <dc:creator>Loaden</dc:creator> <category><![CDATA[Belästigung der Allgemeinheit - mein privater Weblog]]></category> <category><![CDATA[Administration]]></category> <category><![CDATA[beenden]]></category> <category><![CDATA[kill processes]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Prozesse]]></category> <category><![CDATA[Tutorial]]></category><guid isPermaLink="false">http://www.monkey-business.biz/?p=1166</guid> <description><![CDATA[Das Beenden bzw. killen von Prozessen unter Linux / Unixoiden Systemen erfolgt in der Regel über das kill-Kommando in der Konsole. Bevor dieses Kommando zum &#8220;killen&#8221; des Prozessen benutzbar ist muss jedoch die Prozess ID ermittelt werden. Für das ermitteln der Prozess ID empfehle ich die Konsolen-Kommando Kombination: ps aux &#124; grep &#60;PROZESSNAME&#62; &#60;PROZESSNAME&#62; ist [...]]]></description> <content:encoded><![CDATA[<p>Das Beenden bzw. killen von Prozessen unter Linux / Unixoiden Systemen erfolgt in der Regel über das kill-Kommando in der Konsole. Bevor dieses Kommando zum &#8220;killen&#8221; des Prozessen benutzbar ist muss jedoch die Prozess ID ermittelt werden. Für das ermitteln der Prozess ID empfehle ich die Konsolen-Kommando Kombination:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ps</span> aux <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #000000; font-weight: bold;">&lt;</span>PROZESSNAME<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div><p>&lt;PROZESSNAME&gt; ist mit dem Prozess Name zu ersetzen. Beispielsweise &#8220;apache&#8221;. Das &#8220;apache&#8221; Beispiel beschert mir auf einem Server diese Ausgabe:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">www-data <span style="color: #000000;">18148</span>  <span style="color: #000000;">0.0</span>  <span style="color: #000000;">0.1</span> <span style="color: #000000;">232000</span>  <span style="color: #000000;">8664</span> ?        S    Nov18   <span style="color: #000000;">0</span>:00 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2 <span style="color: #660033;">-k</span> start
www-data <span style="color: #000000;">18158</span>  <span style="color: #000000;">0.0</span>  <span style="color: #000000;">0.1</span> <span style="color: #000000;">232000</span>  <span style="color: #000000;">8688</span> ?        S    Nov18   <span style="color: #000000;">0</span>:00 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2 <span style="color: #660033;">-k</span> start</pre></div></div><p>Es ist auch möglich, sofern der genaue Prozessename bekannt ist, das Kommando &#8220;pidof&#8221; zu nutzen.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">pidof</span> <span style="color: #000000; font-weight: bold;">&lt;</span>PROZESSNAME<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div><p>Der Output zu diesem Befehl enthält die Prozess ID&#8217;s oder die Prozess ID je nach Anzahl der laufenden Prozesse mit dem selben Namen.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">8664</span> <span style="color: #000000;">8688</span></pre></div></div><p>Der zweite Schritt ist das eigentliche Beenden des Prozesses mit Hilfe des Kommandos kill.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #000000; font-weight: bold;">&lt;</span>PROZESSID<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span>PROZESSID<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div><p>Prozess ID&#8217;s können mit einem Leerzeichen separiert angegeben werden. Sollte sich auf diesem Wege ein Prozess nicht beenden lassen kann mit der Option &#8220;-9&#8243; des Befehls kill entgegen gewirkt werden.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-9</span> <span style="color: #000000; font-weight: bold;">&lt;</span>PROZESSID<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div><p>In diesem Fall wird der Prozess &#8220;hart&#8221; beendet. Es können ebenfalls mehrere ID&#8217;s mit einem Leerzeichen separiert werden.<br /> Eine andere Art mehrere Prozesse auf einen Streich zu terminieren stellt der Befehl killall da.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-i</span> <span style="color: #000000; font-weight: bold;">&lt;</span>PROZESSNAME<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div><p>Der Parameter &#8220;-i&#8221; sorgt dafür das vor dem Beenden jedes Prozesses nochmals nachgefragt wird ob man ihn wirklich beenden möchte.  Weitere wichtige Optionen sind die Befehle:</p><ul><li>-u &lt;UNIXUSERID&gt; <em>beendet die Prozesse des gewählen UNIX Benutzers</em></li><li>-g &lt;PROZESSGRUPPENID&gt; <em>beendet die Prozesse der gewählten Prozessgruppe</em></li></ul><p>Die Möglichkeit mehrere Prozesse mit einem Befehl zu beenden hat mir persönlich oft weitergeholfen als Server Dienste am spinnen waren. Schönes Wochenende. <img src='http://www.monkey-business.biz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p><p><strong>EDIT:</strong> Beachte das du zum killen einiger Prozesse als root angemeldet sein musst.</p> ]]></content:encoded> <wfw:commentRss>http://www.monkey-business.biz/1166/linux-prozesse-beenden-kill-processes/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Hürden bei Fail2ban und Spamassasin unter Debian Lenny</title><link>http://www.monkey-business.biz/865/hurden-bei-fail2ban-und-spamassasin-unter-debian-lenny/</link> <comments>http://www.monkey-business.biz/865/hurden-bei-fail2ban-und-spamassasin-unter-debian-lenny/#comments</comments> <pubDate>Fri, 30 Apr 2010 18:34:01 +0000</pubDate> <dc:creator>Loaden</dc:creator> <category><![CDATA[Belästigung der Allgemeinheit - mein privater Weblog]]></category> <category><![CDATA[Administration]]></category> <category><![CDATA[Bugfix]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Fail2ban]]></category> <category><![CDATA[Postfix]]></category> <category><![CDATA[Spamassassin]]></category><guid isPermaLink="false">http://www.monkey-business.biz/?p=865</guid> <description><![CDATA[Beim studieren der Server Logs meines Debian Lenny Servers fiehl mir auf das sehr viele fehlgeschlagene authentifizierungs Versuche am SMTP Daemon von Postfix statt gefunden hatten. Folgende Meldung wiederholte sich mehrfach: Apr 28 15:33:56 mail postfix/smtpd[8110]: warning: unknown[218.248.1.181]: SASL CRAM-MD5 authentication failed: PDM2NjYyMjQ0OTU5OTE5MTMuMTI3MjQ2MTYzNUBFTVAtUz4= Mich wunderte das die IP Adresse nicht nach 3 Versuchen von Fail2ban [...]]]></description> <content:encoded><![CDATA[<p>Beim studieren der Server Logs meines Debian Lenny Servers fiehl mir auf das sehr viele fehlgeschlagene authentifizierungs Versuche am SMTP Daemon von Postfix statt gefunden hatten. Folgende Meldung wiederholte sich mehrfach:</p><div class="wp_syntax"><div class="code"><pre class="log" style="font-family:monospace;">Apr 28 15:33:56 mail postfix/smtpd[8110]: warning: unknown[218.248.1.181]: SASL CRAM-MD5 authentication failed: PDM2NjYyMjQ0OTU5OTE5MTMuMTI3MjQ2MTYzNUBFTVAtUz4=</pre></div></div><p>Mich wunderte das die IP Adresse nicht nach 3 Versuchen von Fail2ban (Version 0.8.3-2sid1) gebannt wurde. Es hat sich herausgestellt das der Reguläre Ausdruck den Fail2ban für das erkennen Fehlgeschlagener authentifizierungs Versuche nicht mit der Log-Nachricht übereinstimmt. Ein Entfernen des $ am Ende des Regulären Ausdrucks (failregex) in der Datei /etc/fail2ban/filter.d/sasl.conf reichte aus um die Logs passend zu filtern.</p><p><strong>Warum das $ entfernen?</strong><br /> Das $ steht in einem Regulären Ausdruck für das Ende der zu suchenden Zeichenkette. Da aber nach &#8220;authentication failed&#8221; in dem Log Eintrag weitere Zeichen folgen passt der Reguläre Ausdruck nicht zum Logeintrag.</p><div class="wp_syntax"><div class="code"><pre class="log" style="font-family:monospace;">failregex = : warning: [-._\w]+\[&lt;HOST&gt;\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed</pre></div></div><p>Ist meine aktueller Eintrag um fehlgeschlagene authentifizierungs Versuche am Postfix SMTP Daemon zu erkennen.</p><p>Spamassassin füllte meine Logs zum selben Zeitpunkt mit:</p><div class="wp_syntax"><div class="code"><pre class="log" style="font-family:monospace;">Apr 28 00:31:27 mail spamd[21987]: spamd: creating default_prefs: /nonexistent/.spamassassin/user_prefs
Apr 28 00:31:27 mail spamd[21987]: config: cannot write to /nonexistent/.spamassassin/user_prefs: No such file or directory
Apr 28 00:31:27 mail spamd[21987]: spamd: failed to create readable default_prefs: /nonexistent/.spamassassin/user_prefs</pre></div></div><p>Eine weitere Lösung musste her&#8230; Da Spamassassin bei mir unter dem Benutzer nobody läuft und dieser zu diesem Zeitpunkt kein gültiges Heimatverzeichnis in der /etc/passwd Datei hinterlegt hatte blieben mir sinnvolle 2 Möglichkeiten. Zum einen das Eintragen eines gültigen Heimatverzeichnisses in die Datei /etc/passwd. (Platzhalter: &lt;VERZEICHNIS&gt;)</p><div class="wp_syntax"><div class="code"><pre class="log" style="font-family:monospace;">nobody:x:65534:65534:nobody:&lt;VERZEICHNIS&gt;:/bin/false</pre></div></div><p>Zum Anderen gab es die Möglichkeit Spamassassin durch eine Änderung in /etc/defaults/spamassassin mit einem virtuellen Verzeichnis zu starten. Hier mein Aktueller Eintrag für standard Startoptionen von Spamassassin:  (Platzhalter: &lt;VERZEICHNIS&gt;)</p><div class="wp_syntax"><div class="code"><pre class="log" style="font-family:monospace;">OPTIONS=&quot;--create-prefs --max-children 5 --helper-home-dir -u nobody -x --virtual-config-dir=&lt;VERZEICHNIS&gt;&quot;</pre></div></div><p>Ich entschied mich für die zweite Möglichkeit (Verzeichnis: /var/spool/spamassassin).</p> ]]></content:encoded> <wfw:commentRss>http://www.monkey-business.biz/865/hurden-bei-fail2ban-und-spamassasin-unter-debian-lenny/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>PHP Shell &#8211; Shellzugriff mit PHP</title><link>http://www.monkey-business.biz/817/php-shell-shellzugriff-mit-php/</link> <comments>http://www.monkey-business.biz/817/php-shell-shellzugriff-mit-php/#comments</comments> <pubDate>Sat, 24 Apr 2010 17:37:55 +0000</pubDate> <dc:creator>Loaden</dc:creator> <category><![CDATA[Belästigung der Allgemeinheit - mein privater Weblog]]></category> <category><![CDATA[Administration]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Shell]]></category><guid isPermaLink="false">http://www.monkey-business.biz/?p=817</guid> <description><![CDATA[Shellzugriff aus dem Browser heraus ist nicht nur geschickt sondern in streng konfigurierten Netzwerken auch die einzige Möglichkeit Shellzugriff auf den Server zu bekommen. Hierfür kann ich dir PHP Shell empfehlen. Shellkommandos lassen sich damit ausführen und die Ergebnisse der Kommandos ansehen. Leider lassen sich Programme wie Nano mit der PHP Shell nicht ausführen. Autovervollständigung [...]]]></description> <content:encoded><![CDATA[<p>Shellzugriff aus dem Browser heraus ist nicht nur geschickt sondern in streng konfigurierten Netzwerken auch die einzige Möglichkeit Shellzugriff auf den Server zu bekommen. Hierfür kann ich dir <a href="http://phpshell.sourceforge.net/" title="PHP Shell Projekt Webseite" target="_blank">PHP Shell</a> empfehlen. Shellkommandos lassen sich damit ausführen und die Ergebnisse der Kommandos ansehen.</p><p>Leider lassen sich Programme wie Nano mit der PHP Shell nicht ausführen. Autovervollständigung mittels TAB unterstützt das Shell Werkzeug ebenfalls nicht.</p><p>Neben dem starten des PHP Shell Scriptes als root ist es eine weitere Vorraussetzung  &#8220;Safe Mode&#8221; zu deaktivieren und das Ausführen der Funktion proc_open() zu erlauben.</p><p>Ich kann euch diese kleine Webapplikation nur ans Herz legen.</p><p>Links:</p><ul><li><a href="http://phpshell.sourceforge.net/" title="PHP Shell Projekt Webseite" target="_blank">Projektseite auf Sourceforge</a></li></ul> ]]></content:encoded> <wfw:commentRss>http://www.monkey-business.biz/817/php-shell-shellzugriff-mit-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Linux: Löschen von archivierten Log Dateien</title><link>http://www.monkey-business.biz/665/linux-loschen-von-archivierten-log-dateien/</link> <comments>http://www.monkey-business.biz/665/linux-loschen-von-archivierten-log-dateien/#comments</comments> <pubDate>Sun, 11 Apr 2010 15:15:33 +0000</pubDate> <dc:creator>Loaden</dc:creator> <category><![CDATA[Belästigung der Allgemeinheit - mein privater Weblog]]></category> <category><![CDATA[Administration]]></category> <category><![CDATA[Dateien]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Log]]></category> <category><![CDATA[Shell]]></category><guid isPermaLink="false">http://www.monkey-business.biz/?p=665</guid> <description><![CDATA[Jeder Daemon auf einem Linux System führt eine Log Datei im Verzeichnis /var/log. Ab einer gewissen Laufzeit finden sich dort mehere Megabyte an archivierten Log Dateien. Das händische löschen von archivierten Log Datein ist eine nervige Sache. Um mir Nerven und Zeit zu ersparen habe ich mir ein Script geschrieben das mir diese Arbeit abnimmt. [...]]]></description> <content:encoded><![CDATA[<p>Jeder Daemon auf einem Linux System führt eine Log Datei im Verzeichnis /var/log. Ab einer gewissen Laufzeit finden sich dort mehere Megabyte an archivierten Log Dateien. Das händische löschen von archivierten Log Datein ist eine nervige Sache. Um mir Nerven und Zeit zu ersparen habe ich mir ein Script geschrieben das mir diese Arbeit abnimmt.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Author: Tobias Jäck</span>
<span style="color: #666666; font-style: italic;">## License: GPL version 3</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Logfile</span>
<span style="color: #007800;">LOGFILE</span>=<span style="color: #ff0000;">&quot;/var/log/cleanup.log&quot;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">find</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> <span style="color: #660033;">-iname</span> <span style="color: #000000; font-weight: bold;">*</span>.gz <span style="color: #660033;">-type</span> f <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-fv</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</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>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>		
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">else</span>	
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div><p>Das Script sucht mit &#8220;find&#8221; im Verzeichnis /var/log nach archivierten Log Dateien (Dateien mit der Endung .gz) und entfernt diese. Ironischer Weise legt das Script ebenfalls eine Log Datei an (/var/log/cleanup.log) in der gelöschte Dateien und Probleme niedergeschrieben werden.</p> ]]></content:encoded> <wfw:commentRss>http://www.monkey-business.biz/665/linux-loschen-von-archivierten-log-dateien/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Apache2 Server Signatur ausblenden &#8211; &#8220;Security-by-Obscurity&#8221;</title><link>http://www.monkey-business.biz/737/apache2-server-signatur-ausblenden-security-by-obscurity/</link> <comments>http://www.monkey-business.biz/737/apache2-server-signatur-ausblenden-security-by-obscurity/#comments</comments> <pubDate>Wed, 17 Mar 2010 16:02:25 +0000</pubDate> <dc:creator>Loaden</dc:creator> <category><![CDATA[Belästigung der Allgemeinheit - mein privater Weblog]]></category> <category><![CDATA[Administration]]></category> <category><![CDATA[Apache2]]></category> <category><![CDATA[ServerSignature]]></category><guid isPermaLink="false">http://www.monkey-business.biz/?p=737</guid> <description><![CDATA[Durch das Verstecken von Informationen macht man es Angreifern schwieriger etwas über das System herauszufinden. Der Apache2 zeigt dem Angreifer beim Aufruf einer nicht vorhandenen Datei vom Server welche Apache2 Server Version installiert ist, welche Patches verwendet werden und welche Interpreter auf dem Server installiert sind. Diese Informationen reichen aus um in Exploit Datenbanken nach [...]]]></description> <content:encoded><![CDATA[<p>Durch das Verstecken von Informationen macht man es Angreifern schwieriger etwas über das System herauszufinden. Der Apache2 zeigt dem Angreifer beim Aufruf einer nicht vorhandenen Datei vom Server welche Apache2 Server Version installiert ist, welche Patches verwendet werden und welche Interpreter auf dem Server installiert sind. Diese Informationen reichen aus um in Exploit Datenbanken nach passenden Exploits zu suchen. Das ausblenden dieser Information geht leicht von der Hand. Es gibt also keine Grund diese nicht zu verstecken.</p><p>Meine Wahl fällt dabei auf das erstellen einer weiteren Konfigurationsdatei in /etc/apache2/conf.d. Dateien in diesem Verzeichnis werden automatisiert eingelesen und für die Apache2 Einstellungen verwendet. In der Datei wird die Option ServerSignature verwendet um, wie schon am Optionsname zu erkennen, die Server Signatur auszublenden. Der Inhalt der Datei, benannt server_signature, gestaltet sich beim mir so:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ServerSignature Off
ServerTokens Prod</pre></div></div><p>Es kann auch die Datei /etc/apache2/httpd.conf um diesen Eintrag zu erweitert werden anstatt eine separate Konfigurationsdatei anzulegen. Ebenfalls ist es möglich nur Teile der Server Signatur auszublenden. Mehr dazu findest du <a href="http://httpd.apache.org/docs/2.0/mod/core.html#serversignature" title="Apache2 Konfiguration: Server Signature" target="_blank">hier</a>. Interessant ist, das die Server Variable $_SERVER['SERVER_SIGNATURE'] in PHP sich mit der Änderung der ServerSignature ändert. In den gängigen Webapplikationen wird diese Variable nicht verwendet. Ich wüsste auch keinen Einsatzbereich für diese.</p><p>ServerTokens setzt die Signatur des Servers im HTTP Response Header auf ein Minimum. Die Ausgabe beim Parameter &#8220;Prod&#8221; ist lediglich &#8220;Apache&#8221;. Ein entfernen aller Informationen zum Server ist nur mit dem editieren des Apache2 Quellcodes oder über die Erweiterung mod_security möglich. Jedoch bin nichtmal ich so paranoid diese Möglichkeit zu nutzen.</p> ]]></content:encoded> <wfw:commentRss>http://www.monkey-business.biz/737/apache2-server-signatur-ausblenden-security-by-obscurity/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Debian Backup mittels Paketlisten &amp; MySQL Dumps &amp; FTP Upload</title><link>http://www.monkey-business.biz/282/debian-backup-mittels-paketlisten-mysql-dumps-ftp-upload/</link> <comments>http://www.monkey-business.biz/282/debian-backup-mittels-paketlisten-mysql-dumps-ftp-upload/#comments</comments> <pubDate>Sun, 14 Mar 2010 13:39:29 +0000</pubDate> <dc:creator>Loaden</dc:creator> <category><![CDATA[Belästigung der Allgemeinheit - mein privater Weblog]]></category> <category><![CDATA[Administration]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[dpkg]]></category> <category><![CDATA[FTP]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[Paketlisten]]></category> <category><![CDATA[Shell]]></category> <category><![CDATA[Ubuntu]]></category><guid isPermaLink="false">http://www.monkey-business.biz/?p=282</guid> <description><![CDATA[Auf der Suche nach einem Backup Shell Script für meinen Debian Server wurde ich in den weiten des Internets nicht fündig. Zumindest fand ich kein Script das genau das tat was ich wollte. Also machte ich mich selbst ans Werk. Vorweg: Das Script erstellt nicht einfach eine simple Kopie des Festplatteninhalts. Dies verbraucht meiner Meinung [...]]]></description> <content:encoded><![CDATA[<p>Auf der Suche nach einem Backup Shell Script für meinen Debian Server wurde ich in den weiten des Internets nicht fündig. Zumindest fand ich kein Script das genau das tat was ich wollte. Also machte ich mich selbst ans Werk. Vorweg: Das Script erstellt nicht einfach eine simple Kopie des Festplatteninhalts. Dies verbraucht meiner Meinung nach zu viel Speicherplatz. Sämtliche Debian Binarys müssen nämlich nicht gesichert werden. Denn diese sind von den Servern aus der sources.list abrufbar. Einzig und allein die Binarys unter /usr/local/ werden, neben den Konfigurationsdateien unter /etc/ und den Dateien unter /var/ /home/ und /root/, gesichtert. Natürlich können diese Verzeichnisse geändert werden. Es reicht die Variable TOBACKUP im Konfigurationsteil des Scriptes um die entsprechenden Verzeichnisse zu erweitern oder mit Hilfe der Variable TOEXCLUDE Unterverzeichnisse vom Backup auszuschließen. Die Kernel Version, Distribution, Architektur und der Installationszeitpunkt des Systems werden nochmals seperat in der Datei uname.txt gesichert.</p><p>Ebenso erstellt das Script SQL Dumps von allen MySQL Datenbanken des Servers und läd das gesamte Backup, verschlüsselt oder nur komprimiert, optional auch auf einen FTP Space übertragen. Wichtig ist das das Verzeichnis das in OUTDIR eingetragen ist exisitert. Sowohl bei lokalem speichern des Backups als auch beim remote Backup Vorgang auf den FTP Space. Eine Übertragung auf einen FTP Backup Space erfolgt nur, wenn FTP Zugangsdaten hinterlegt sind. Sollte etwas in die Option BACKUPPASS eingetragen sein verschlüsselt das Script die Daten mit GnuPG.</p><p>Die Kommentare im Script habe ich in englisch gehalten. Damit sollte eigentlich jeder zurecht kommen und ich muss das Script nicht mehrsprachig kommentiert online stellen. Auf alle Konfigurationsoptionen möchte ich hier im Text nicht weiter eingehen. Die Variablenbezeichnungen sowie die Kommentare sollten alles erklären.</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Author: Tobias Jäck</span>
<span style="color: #666666; font-style: italic;">## License: GPL version 3</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##</span>
<span style="color: #666666; font-style: italic;">## &lt;Configuration&gt;</span>
<span style="color: #666666; font-style: italic;">##</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Backup prefix</span>
<span style="color: #007800;">PREFIX</span>=<span style="color: #ff0000;">&quot;yourprefix_&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Dirs which should be backed</span>
<span style="color: #007800;">TOBACKUP</span>=<span style="color: #ff0000;">&quot;/root/ /home/ /etc/ /var/ /usr/local/&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Dirs which shouldn't be backed</span>
<span style="color: #007800;">TOEXCLUDE</span>=<span style="color: #ff0000;">&quot;/yourdirstoexclude/&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## MySQL login data</span>
<span style="color: #007800;">MYSQLUSER</span>=<span style="color: #ff0000;">&quot;yoursqluser&quot;</span>
<span style="color: #007800;">MYSQLPASS</span>=<span style="color: #ff0000;">&quot;yoursqlpass&quot;</span>
<span style="color: #007800;">MYSQLHOST</span>=<span style="color: #ff0000;">&quot;yoursqlhost&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Dir to save backup</span>
<span style="color: #007800;">OUTDIR</span>=<span style="color: #ff0000;">&quot;yourdirtosave&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## FTP login form the backup FTP server (optional)</span>
<span style="color: #007800;">FTPHOST</span>=<span style="color: #ff0000;">&quot;optionalyourftphost&quot;</span>
<span style="color: #007800;">FTPUSER</span>=<span style="color: #ff0000;">&quot;optionalyourftpuser&quot;</span>
<span style="color: #007800;">FTPPASS</span>=<span style="color: #ff0000;">&quot;optionalyourftppss&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Backup password (optional)</span>
<span style="color: #007800;">BACKUPPASS</span>=<span style="color: #ff0000;">&quot;optionalyourpassword&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Working dir</span>
<span style="color: #007800;">WORKINGDIR</span>=<span style="color: #ff0000;">&quot;/tmp/&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Logfile</span>
<span style="color: #007800;">LOGFILE</span>=<span style="color: #ff0000;">&quot;/var/log/<span style="color: #007800;">${PREFIX}</span>backup.log&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##</span>
<span style="color: #666666; font-style: italic;">## &lt;/Configuration&gt;</span>
<span style="color: #666666; font-style: italic;">##</span>
&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;<span style="color: #007800;">$OUTDIR</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">## Set prozess priority</span>
	renice <span style="color: #660033;">-19</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$$</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">## Set I/O priority</span>
	ionice <span style="color: #660033;">-c2</span> <span style="color: #660033;">-n1</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$$</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">## Date and time</span>
	<span style="color: #007800;">DATE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%Y-%m-%d-%H-%M-%S&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">## Create and enter working dir</span>
	<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #800000;">${WORKINGDIR}</span><span style="color: #800000;">${PREFIX}</span><span style="color: #800000;">${DATE}</span>
	<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #800000;">${WORKINGDIR}</span><span style="color: #800000;">${PREFIX}</span><span style="color: #800000;">${DATE}</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">## Save version</span>
	<span style="color: #c20cb9; font-weight: bold;">uname</span> <span style="color: #660033;">-a</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;uname.txt&quot;</span>
	<span style="color: #007800;">TOBACKUP</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${TOBACKUP}</span> uname.txt&quot;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">## Create a list with installed deb pakets</span>
	<span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">--get-selections</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;deb.list&quot;</span>
	<span style="color: #007800;">TOBACKUP</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${TOBACKUP}</span> deb.list&quot;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">## Create MySQL dump environment</span>
	<span style="color: #c20cb9; font-weight: bold;">mkdir</span> mysqldumps<span style="color: #000000; font-weight: bold;">/</span>
	<span style="color: #007800;">TOBACKUP</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${TOBACKUP}</span> mysqldumps/&quot;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">## Create MySQL dumps from all databases</span>
	<span style="color: #007800;">DBS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(mysql  -h $MYSQLHOST -u $MYSQLUSER -p$MYSQLPASS -Bse 'show databases' 2&gt;&gt; $LOGFILE)</span>&quot;</span>	
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">## Delete temporary files</span>
		<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-r</span> <span style="color: #800000;">${WORKINGDIR}</span><span style="color: #800000;">${PREFIX}</span><span style="color: #800000;">${DATE}</span>
		<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">for</span> DB <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$DBS</span>; <span style="color: #000000; font-weight: bold;">do</span>
		mysqldump <span style="color: #660033;">-h</span> <span style="color: #007800;">$MYSQLHOST</span> <span style="color: #660033;">-u</span> <span style="color: #007800;">$MYSQLUSER</span> -p<span style="color: #007800;">$MYSQLPASS</span> <span style="color: #007800;">$DB</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;mysqldumps/<span style="color: #007800;">${DB}</span>.sql&quot;</span>
	<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">## Exclude dirs</span>
	<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;<span style="color: #007800;">$TOEXCLUDE</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
&nbsp;
		<span style="color: #007800;">TOEXCLUDE</span>=<span style="color: #ff0000;">&quot;--exclude <span style="color: #007800;">${TOEXCLUDE}</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">## Compress and / or encrypt files</span>
	<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;<span style="color: #007800;">$BACKUPPASS</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>	
&nbsp;
		<span style="color: #007800;">VAR_EXTENSION</span>=<span style="color: #ff0000;">&quot;.tar.bz2.gpg&quot;</span>
		<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-cf</span> - <span style="color: #007800;">$TOBACKUP</span> <span style="color: #007800;">$TOEXCLUDE</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">|</span> gpg <span style="color: #660033;">--symmetric</span> <span style="color: #660033;">--bzip2-compress-level</span> <span style="color: #000000;">9</span> <span style="color: #660033;">--passphrase</span> <span style="color: #800000;">${BACKUPPASS}</span>  <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PREFIX}</span><span style="color: #007800;">${DATE}</span><span style="color: #007800;">${VAR_EXTENSION}</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">else</span>
&nbsp;
		<span style="color: #007800;">VAR_EXTENSION</span>=<span style="color: #ff0000;">&quot;.tar.bz2&quot;</span>
		<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-cf</span> - <span style="color: #007800;">$TOBACKUP</span> <span style="color: #007800;">$TOEXCLUDE</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bzip2</span> <span style="color: #660033;">-c</span> <span style="color: #660033;">--best</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PREFIX}</span><span style="color: #007800;">${DATE}</span><span style="color: #007800;">${VAR_EXTENSION}</span>&quot;</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&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;<span style="color: #007800;">$FTPHOST</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$FTPUSER</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$FTPPASS</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">## Save backup on FTP server</span>
		ncftpput <span style="color: #660033;">-u</span> <span style="color: #007800;">$FTPUSER</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$FTPPASS</span> <span style="color: #007800;">$FTPHOST</span> <span style="color: #007800;">$OUTDIR</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PREFIX}</span><span style="color: #007800;">${DATE}</span><span style="color: #007800;">${VAR_EXTENSION}</span>&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">else</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">## Save backup lokal</span>
		<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${PREFIX}</span><span style="color: #007800;">${DATE}</span><span style="color: #007800;">${VAR_EXTENSION}</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$OUTDIR</span>&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">## Delete temporary files</span>
	<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-r</span> <span style="color: #800000;">${WORKINGDIR}</span><span style="color: #800000;">${PREFIX}</span><span style="color: #800000;">${DATE}</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>		
		<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">else</span>	
		<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Error: Output dir is empty&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$LOGFILE</span> 
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div><p>Der Name des komprimierten Backups setzt sich wie folgt zusammen: %Präfix%%Jahr%-%Monat%-%Tag%-%Stunde%-%Minute%-%Sekunde%.tar.bz2. Die Log Datei des Scripts findest du unter /var/log/%Präfix%backup.log. Enthalten sind dort Statistiken und Fehler zur FTP Übertragung sowie kritische Konfigurationsfehler.</p><p>Im Script werden Prozess und I/O Priorität angepasst um den Server nicht an seiner regulären Arbeit zu hindern. Beachte dabei das ein Ausführen von nice nur mit root Rechten möglich ist.</p><p>Mögliche Probleme mit Paketabhängigkeiten sollten sich nach dem erfolgreichen ausführen dieses Befehls erledigt haben:</p><div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> ncftp <span style="color: #c20cb9; font-weight: bold;">bzip2</span> gnupg</pre></div></div><p>Sowohl date als auch tar, nice, ionice dpkg und mysql / mysqldump sind normalerweise auf dem Server vorhanden.</p><p>Bei Fragen oder Problemen scheue nicht die Kommentarfunktion zu verwenden.</p> ]]></content:encoded> <wfw:commentRss>http://www.monkey-business.biz/282/debian-backup-mittels-paketlisten-mysql-dumps-ftp-upload/feed/</wfw:commentRss> <slash:comments>14</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 7/14 queries in 0.008 seconds using disk: basic

Served from: www.monkey-business.biz @ 2012-02-05 02:14:02 -->
