Bookmark, share, and hop your favorite sites with SiteHoppin Toolbar for Firefox!書籤,分享與合您最喜愛的網站與sitehoppin用於Firefox的工具欄!

Back: 1/2 of UK Men Would Give Up Sex For A TV?!?回: 1 / 2的英國男人會放棄性別為電視? ! ?

Forward: What is Soju and How Does it Affect an Entrecard (Ab)user’s Life提出:什麼是燒酒和它如何影響一entrecard (抗體)使用者的生命


DIY Linux Web Server HACK - Automate your MySQL MySQL database backups diy Linux的Web伺服器哈克-自動化你的M ySQLM ySQL數據庫備份

Posted in張貼在 Blog博客 , Cool涼爽的 , DIY Zedomax diy zedomax , DoItYourself! doityourself ! , Educational教育 , Hack哈克 , Linux Linux的 , Ubuntu Ubuntu的 , Web網頁 , Wordpress在WordPress by max on the February 10th, 2008 at 5:24 pm由Max於2008年2月10日在下午5時24分

Okay, I’ve been running dedicated servers for couple years now and I used to mess around with Linux boxes back in college.好吧,我已經運行專用服務器為一,兩年,現在和我以前的爛攤子左右,與Linux箱子回在高校。

Here’s an essential automatic script and a cron job you will need in order to keep your backup automatic .這裡的不可或缺的自動腳本和一個作業您將需要,以保持您的備份自動

Yes, if you get a dedicated server, don’t get their stupid extra $15/month for backing up your database.  (All they do is make scripts like this one and charge you for it)是的,如果您獲得一個專用的服務器,不得到他們愚蠢的額外撥款15/month備份您的數據庫。 (所有他們要做的就是使劇本就像這一次和您收取)

You can follow this example and go spend that money on junk food.您也可以按照這個例子和去花費金錢,對垃圾食品。

So all you have to do is FTP your backup files.因此,所有您需要做的就是您的FTP備份文件。

This is way better than going into your phpMyAdmin and downloading from the web interface since the file is already ready for you to download.這是更好的方式,比去到您的phpmyadmin和下載的網頁介面,自該文件已經準備就緒,可供您下載。

Here’s how you do it:在這裡的你如何去做:

1) Make a new file called backup.sh in your home directory. 1 )讓一個新的文件所謂backup.sh在您的主目錄。 2) Use the following syntax: 2 )使用下列語法:

 mysqldump -u[USERNAME] -p[PASSWORD] –opt [DATABASE NAME] > /root/backup/DATABASE1.sql mysqldump中美[用戶名] - [密碼]選擇[數據庫名稱] > / root/backup/database1.sql 

Here’s an example backup.sh file if you had 2 databases:這裡的一個例子backup.sh文件如果您有二數據庫:

 mysqldump -uUser1 -pPassword1 --opt Database1 > /root/backup/Database1.sql mysqldump -uUser2 -pPassword2 --opt Database2 > /root/backup/Database2.sql tar cvf /root/backup/sqlbackup.tar /root/backup/* mysqldump - uuser1 - ppassword1 -選擇d atabase1> / r oot/backup/database1.sqlm ysqldump- u user2- p password2-選擇da tabase2>/ r o ot/backup/database2.sql焦油cv f/根/備份/s q lbackup.tar/根/備份/ * 

You can test your script by typing this:您可以測試您的腳本中鍵入:

 sh backup.sh的SH backup.sh 

(The mysqldump will overwrite the older file if you run this more than once) ( mysqldump將覆蓋舊文件如果您運行,這一次以上)

3) If everything is working good, now you can put that script to be run once a day in your cron job. 3 )如果一切是工作好,現在您可以把腳本運行每日一次,在您的作業。

For Fedora Core, you can edit this file /etc/cron.d/sa-update為淺頂軟呢帽核心,您可以編輯此文件的/ etc / cron.d /颯更新

Add the following line:添加下面一行:

 10 3 * * * root sh /root/backup/backup.sh 3月10日* * *根的SH /根/備份/ backup.sh 

This will execute the script once a day at 3:10AM.這將執行該腳本每天一次,在上午03點10分。

Now simply download one tar ball file whenever you feel like backing up your database.現在只需下載一焦油球檔案 ,每當你感覺備份您的數據庫。

You can probably change this a little bit and use it for many other things like backing up all your files too.你或許可以改變這一點,並用它為許多其他事情一樣,備份您的所有文件。 (which I do) (我)

If you have multiple servers like me, you can also automate your scripts to download backup databases to each server.如果您有多個服務器和我一樣,您也可以自動化您的腳本下載備份數據庫,以每台服務器。 That keeps things real redundant in case of server failure.不斷的東西,真正是多餘的案件服務器失敗。

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,



1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet) (尚無評)
Loading ... Loading ...載入中...


If you like this post then please subscribe to my如果你喜歡這個職位,然後請訂閱我的 full feed RSS充分飼料的RSS . You can also subscribe by您也可以訂閱 Email電子郵件 .

Got a new hack, DIY, howto, or gadget?得到一個新的入侵, diy ,如何,或小工具? Tip us here提示我們在這裡 .

Search for a Hack:尋找一個哈克:


Bookmark It!書籤它!


| Digg it它digg | SiteHoppin sitehoppin | Wagg It wagg它 |

Related Posts相關文章



TrackBack Trackback跟踪

Email this to a Friend通過電子郵件發送給朋友 Email This Post Email This Post電子郵件這個職位

RSS feed RSS饋送

5 Comments 5評論 »

Comment by 評論 Mike 邁克
2008-02-11 02:24:34 2008年2月11日2時24分34秒

Very useful script.非常有用的腳本。 Thanks.謝謝。

http://packratstudios.com

myavatars 0.2
Comment by 評論 max 最高
2008-02-11 07:15:11 2008年2月11日7時15分11秒

glad it helped!很高興它幫助!

myavatars 0.2
Comment by 評論 Brian Gaut 布賴恩gaut 訂閱評論通過電子郵件
2008-02-11 05:22:04 2008年2月11日5時22分04秒

To further automate the process of backing up, you should set up a LOCAL cron job that downloads the file to your computer.進一步的過程自動化備份,你應該成立一個本地作業下載檔案到您的計算機。

Which is just as easy….這是一樣簡單… … 。 all ya do fetch the remote file:所有亞做市值遠程文件:

wget ftp://Username:Password@www.yoursite.com/backup/sqlbackup.tar ftp://username:password @從www.yoursite.com /備份/ sqlbackup.tar

myavatars 0.2
Comment by 評論 max 最高
2008-02-11 07:14:54 2008年2月11日7時14分54秒

true, that’s if you are using Linux…wait a minute, why am i not using linux!?!誠然,這是如果您正在使用Linux的…且慢,為什麼我沒有使用Linux ! ? !

myavatars 0.2
2008-06-05 16:10:43 2008年6月5日16時10分43秒

Cool script.冷靜的腳本。

I’ve always used a software product to backup my DBs - it was something like database backup generator.我總是用了一個軟件產品,以備份我的都柏林商學院-這是一些像數據庫備份發電機。

You set it to run daily and it’ll back up, email you a download link, and also store as many backups as you need.你將它設置為每天運行,它會備份,以電子郵件通知您下載連結,並存儲作為備份,因為許多您所需要的。

The thing I liked was that you could restore the DB with one click from the admin panel.這件事我很喜歡的是,你可以恢復分貝,與一按,從管理面板。

Craig克雷格

myavatars 0.2
Name (required) 姓名(必填)
E-mail (required - never shown publicly) 電子郵件(必填-從來沒有公開表明)
URI 開放的我們

Subscribe to comments via email 訂閱評論通過電子郵件
Your Comment ( 您的評論( smaller size 面積較小 | | larger size 面積較大 )
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment. 你可以使用<a href="" title=""> <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> <刪除日期時間= “ ” >的<em>的<i> <q cite=""> <strike>的<strong>在您的評論。