﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Tao-随笔分类-Linux</title><link>http://www.blogjava.net/programmer/category/27879.html</link><description /><language>zh-cn</language><lastBuildDate>Fri, 07 Dec 2007 06:20:20 GMT</lastBuildDate><pubDate>Fri, 07 Dec 2007 06:20:20 GMT</pubDate><ttl>60</ttl><item><title>How To: using bash script to backup MySql</title><link>http://www.blogjava.net/programmer/archive/2007/11/13/165573.html</link><dc:creator>wade</dc:creator><author>wade</author><pubDate>Tue, 13 Nov 2007 07:49:00 GMT</pubDate><guid>http://www.blogjava.net/programmer/archive/2007/11/13/165573.html</guid><wfw:comment>http://www.blogjava.net/programmer/comments/165573.html</wfw:comment><comments>http://www.blogjava.net/programmer/archive/2007/11/13/165573.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/programmer/comments/commentRss/165573.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/programmer/services/trackbacks/165573.html</trackback:ping><description><![CDATA[Create a file backup_db.sh, and paste the following contents:  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244,244,244); max-height: 200px"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas,'Courier New',courier,monospace; border-right-style: none; border-left-style: none; background-color: rgb(244,244,244); border-bottom-style: none"><span style="color: rgb(0,128,0)">#get the first parameter as the database name</span>
DATABASE=$1
<span style="color: rgb(0,128,0)">#if no database specified, then you can set the default one</span>
<span style="color: rgb(0,0,255)">if</span> [ -z $DATABASE ]; then<br>
DATABASE=default_database_name_here<br>
fi<br>
<br>
<span style="color: rgb(0,128,0)">#mysql user and password to backup the database.</span>
MYSQLUSER=mysql_user
MYSQLPWD=mysql_password
<span style="color: rgb(0,128,0)">#path to backup</span>
ARCHIVEPATH=~/backup/db_backup
DATE=`date +%Y%m%d`
YEAR=`date +%Y`
MONTH=`date +%m`
FOLDER_MONTH=$ARCHIVEPATH/$YEAR$MONTH
<span style="color: rgb(0,0,255)">if</span> [ ! -d $FOLDER_MONTH ]; then<br>
echo <span style="color: rgb(0,96,128)">"mkdir $FOLDER_MONTH"</span>
mkdir $FOLDER_MONTH
fi
<span style="color: rgb(0,128,0)"># Backup</span>
echo <span style="color: rgb(0,96,128)">"mysqldump -u$MYSQLUSER -p$MYSQLPWD $DATABASE | gzip &gt; $FOLDER_MONTH/$DATABASE-$DATE.sql.gz"</span>
mysqldump -u$MYSQLUSER -p$MYSQLPWD $DATABASE | gzip &gt; $FOLDER_MONTH/$DATABASE-$DATE.sql.gz
</pre></div>
<p>&nbsp;</p>
<p>and you can add the script to cron job under *nix and schedule under windows:</p>
<p>*nix:</p>
<p>Save the following text in file: db_backup.at</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244,244,244); max-height: 200px"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas,'Courier New',courier,monospace; border-right-style: none; border-left-style: none; background-color: rgb(244,244,244); border-bottom-style: none">10 * * * * ~/backup/backup_db.sh databasename</pre></div>
<p>and call </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244,244,244); max-height: 200px"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas,'Courier New',courier,monospace; border-right-style: none; border-left-style: none; background-color: rgb(244,244,244); border-bottom-style: none">crontab db_backup.at</pre></div>
<p>You need to change the period to run the script for your business, e.g. each day, each week etc.</p><img height="1" alt="" src="http://www.cnblogs.com/taotao/aggbug/958099.html" width="1"><br>
<div>&nbsp;</div><img src ="http://www.blogjava.net/programmer/aggbug/165573.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/programmer/" target="_blank">wade</a> 2007-11-13 15:49 <a href="http://www.blogjava.net/programmer/archive/2007/11/13/165573.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Add two ips to one NIC in ubuntu</title><link>http://www.blogjava.net/programmer/archive/2007/09/25/165564.html</link><dc:creator>wade</dc:creator><author>wade</author><pubDate>Tue, 25 Sep 2007 06:37:00 GMT</pubDate><guid>http://www.blogjava.net/programmer/archive/2007/09/25/165564.html</guid><wfw:comment>http://www.blogjava.net/programmer/comments/165564.html</wfw:comment><comments>http://www.blogjava.net/programmer/archive/2007/09/25/165564.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/programmer/comments/commentRss/165564.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/programmer/services/trackbacks/165564.html</trackback:ping><description><![CDATA[<p>edit file: /etc/network/interfaces </p> <p>the original content should be something like:</p> <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244,244,244); max-height: 200px"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas,'Courier New',courier,monospace; border-right-style: none; border-left-style: none; background-color: rgb(244,244,244); border-bottom-style: none"><span style="color: rgb(0,128,0)"># The primary network interface</span>
auto eth0
iface eth0 inet static
address 192.168.0.5
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
<span style="color: rgb(0,128,0)"># dns-* options are implemented by the resolvconf package, if installed</span>
dns-nameservers 192.168.0.1 </pre></div>
<p>add the following settings in the file: </p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244,244,244); max-height: 200px"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas,'Courier New',courier,monospace; border-right-style: none; border-left-style: none; background-color: rgb(244,244,244); border-bottom-style: none">auto eth0:1<br>
iface eth0:1 inet static<br>
address 192.168.0.6<br>
netmask 255.255.255.0<br>
network 192.168.0.0<br>
broadcast 192.168.0.255<br>
gateway 192.168.0.1<br>
<br>
<span style="color: rgb(0,128,0)"># dns-* options are implemented by the resolvconf package, if installed</span>
dns-nameservers 192.168.0.1 </pre></div>
<p>&nbsp;</p>
<p>run command in root mode:</p>
<p>/etc/init.d/networking restart</p>
<p>that's all. you can run ifconfig to check if it works.</p>
<p>I tested it in ubuntu 6.10.</p><img height="1" alt="" src="http://www.cnblogs.com/taotao/aggbug/905452.html" width="1"><br>
<div>&nbsp;</div><img src ="http://www.blogjava.net/programmer/aggbug/165564.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/programmer/" target="_blank">wade</a> 2007-09-25 14:37 <a href="http://www.blogjava.net/programmer/archive/2007/09/25/165564.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>