<?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>Thepozer</title>
	<atom:link href="http://www.thepozer.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thepozer.com</link>
	<description></description>
	<lastBuildDate>Wed, 20 Oct 2010 08:23:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Backup de tous les utilisateurs d&#8217;un serveur mysql</title>
		<link>http://www.thepozer.com/2010/10/19/backup-all-mysql-user-from-server/</link>
		<comments>http://www.thepozer.com/2010/10/19/backup-all-mysql-user-from-server/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 15:20:19 +0000</pubDate>
		<dc:creator>pozer</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.thepozer.com/?p=35</guid>
		<description><![CDATA[Voici un petit script qui permet de générer un backup SQL de tous les utilisateur mysql d&#8217;un serveur. Il utilise le bash et le client mysql en ligne de commande. Pour l&#8217;utiliser, il suffit de lui donner comme paramètres le nom de la machine (Paramètre -h), le login (-u) et le mot de passe (-p). [...]]]></description>
			<content:encoded><![CDATA[<p>Voici un petit script qui permet de générer un backup SQL de tous les utilisateur mysql d&#8217;un serveur.</p>
<p>Il utilise le bash et le client mysql en ligne de commande. Pour l&#8217;utiliser, il suffit de lui donner comme paramètres le nom de la machine (Paramètre -h), le login (-u) et le mot de passe (-p).</p>
<div class="codecolorer-container text geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$&gt; ./backup-user.sh -h localhost -u login -p  passwd</div></td></tr></tbody></table></div>
<p><span id="more-35"></span></p>
<p>Voici le code source :</p>
<div class="codecolorer-container bash geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><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 />
<br />
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">getopts</span> &nbsp;<span style="color: #ff0000;">':h:u:p:'</span> flag ; <span style="color: #000000; font-weight: bold;">do</span><br />
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$flag</span> <span style="color: #000000; font-weight: bold;">in</span><br />
h <span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">sHost</span>=<span style="color: #007800;">$OPTARG</span> <span style="color: #000000; font-weight: bold;">;;</span><br />
u <span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">sLogin</span>=<span style="color: #007800;">$OPTARG</span> <span style="color: #000000; font-weight: bold;">;;</span><br />
p <span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">sPasswd</span>=<span style="color: #007800;">$OPTARG</span> <span style="color: #000000; font-weight: bold;">;;</span><br />
<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">;;</span><br />
<span style="color: #000000; font-weight: bold;">esac</span><br />
<span style="color: #000000; font-weight: bold;">done</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;x&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;x<span style="color: #007800;">${sPasswd}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span><br />
<span style="color: #007800;">sPasswd</span>=<span style="color: #ff0000;">&quot;-p<span style="color: #007800;">${sPasswd}</span>&quot;</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #000000; font-weight: bold;">for</span> u <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span>mysql <span style="color: #660033;">-h</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sHost</span>&quot;</span> <span style="color: #660033;">-u</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sLogin</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${sPasswd}</span>&quot;</span> <span style="color: #660033;">--skip-column-names</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;SELECT DISTINCT CONCAT('\'', User, '\'@\'', Host, '\'') FROM mysql.user;&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">do</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;### User : <span style="color: #007800;">$u</span>&quot;</span> ;<br />
mysql <span style="color: #660033;">-h</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sHost</span>&quot;</span> <span style="color: #660033;">-u</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sLogin</span>&quot;</span> <span style="color: #ff0000;">&quot;-p<span style="color: #007800;">${sPasswd}</span>&quot;</span> <span style="color: #660033;">--skip-column-names</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;SHOW GRANTS FOR <span style="color: #007800;">$u</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> l ; <span style="color: #000000; font-weight: bold;">do</span> &nbsp;<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$l</span> ;<span style="color: #000099; font-weight: bold;">\n</span>FLUSH PRIVILEGES ;&quot;</span> ; <span style="color: #000000; font-weight: bold;">done</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> ;<br />
<span style="color: #000000; font-weight: bold;">done</span></div></td></tr></tbody></table></div>
<p>Et voici une version sans paramètre</p>
<div class="codecolorer-container bash geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><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 />
<br />
<span style="color: #007800;">sHost</span>=<span style="color: #ff0000;">'localhost'</span> ;<br />
<span style="color: #007800;">sLogin</span>=<span style="color: #ff0000;">'login'</span> ;<br />
<span style="color: #007800;">sPasswd</span>=<span style="color: #ff0000;">'passwd'</span> ;<br />
<br />
<span style="color: #000000; font-weight: bold;">for</span> u <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span>mysql <span style="color: #660033;">-h</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sHost</span>&quot;</span> <span style="color: #660033;">-u</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sLogin</span>&quot;</span> <span style="color: #ff0000;">&quot;-p<span style="color: #007800;">${sPasswd}</span>&quot;</span> <span style="color: #660033;">--skip-column-names</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;SELECT DISTINCT CONCAT('\'', User, '\'@\'', Host, '\'') FROM mysql.user;&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">do</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;### User : <span style="color: #007800;">$u</span>&quot;</span> ;<br />
mysql <span style="color: #660033;">-h</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sHost</span>&quot;</span> <span style="color: #660033;">-u</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$sLogin</span>&quot;</span> <span style="color: #ff0000;">&quot;-p<span style="color: #007800;">${sPasswd}</span>&quot;</span> <span style="color: #660033;">--skip-column-names</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;SHOW GRANTS FOR <span style="color: #007800;">$u</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> l ; <span style="color: #000000; font-weight: bold;">do</span> &nbsp;<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$l</span> ;<span style="color: #000099; font-weight: bold;">\n</span>FLUSH PRIVILEGES ;&quot;</span> ; <span style="color: #000000; font-weight: bold;">done</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> ;<br />
<span style="color: #000000; font-weight: bold;">done</span></div></td></tr></tbody></table></div>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Backup+de+tous+les+utilisateurs+d%E2%80%99un+serveur+mysql+http%3A%2F%2Fis.gd%2FA9bdAd" title="Post to Twitter"><img class="nothumb" src="http://www.thepozer.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Backup+de+tous+les+utilisateurs+d%E2%80%99un+serveur+mysql+http%3A%2F%2Fis.gd%2FA9bdAd" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.thepozer.com/2010/10/19/backup-all-mysql-user-from-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bonjour tout le monde&#160;!</title>
		<link>http://www.thepozer.com/2010/06/29/bonjour-tout-le-monde/</link>
		<comments>http://www.thepozer.com/2010/06/29/bonjour-tout-le-monde/#comments</comments>
		<pubDate>Tue, 29 Jun 2010 13:21:36 +0000</pubDate>
		<dc:creator>pozer</dc:creator>
				<category><![CDATA[Autres]]></category>

		<guid isPermaLink="false">http://www.thepozer.com/?p=1</guid>
		<description><![CDATA[Ici, bientôt, quelques astuces techniques et scripts shells &#8230; de temps à autres &#8230; Tweet This Post]]></description>
			<content:encoded><![CDATA[<p>Ici, bientôt, quelques astuces techniques et scripts shells &#8230; de temps à autres &#8230; <img src='http://www.thepozer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Bonjour+tout+le+monde%C2%A0%21+http%3A%2F%2Fis.gd%2FfefYyw" title="Post to Twitter"><img class="nothumb" src="http://www.thepozer.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Bonjour+tout+le+monde%C2%A0%21+http%3A%2F%2Fis.gd%2FfefYyw" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.thepozer.com/2010/06/29/bonjour-tout-le-monde/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

