Back: 1/2 of UK Men Would Give Up Sex For A TV?!?回: 1 / 2的英國男人會放棄性別為電視? ! ?
DIY Linux Web Server HACK - Automate your MySQL MySQL database backups diy Linux的Web伺服器哈克-自動化你的M ySQLM ySQL數據庫備份
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.不斷的東西,真正是多餘的案件服務器失敗。
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相關文章
- Zedomax Server Upgrade Complete! zedomax Server升級完成!
- Data Browser allows you to manipulate MySQL database in a Snap!數據瀏覽器可讓您操控MySQL數據庫在一個管理單元!
- DIY Wordpress HACK - How to decrease the load on your Wordpress blog by 5 factors! diy的WordPress哈克-如何減少負荷對您的W ordPress所博客由5個因素!
- Why not host yourself為什麼不自己主機
- DIY Linux DoS HACK - HOWTO Limit your the max number of TCP connections to your Web Server! diy的Linux DOS的攻擊-如何限制您的最高數目的T CP連接到您的W eb服務器!
TrackBack Trackback跟踪
Email this to a Friend通過電子郵件發送給朋友
Email This Post電子郵件這個職位 






















Very useful script.非常有用的腳本。 Thanks.謝謝。
http://packratstudios.com
glad it helped!很高興它幫助!
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
true, that’s if you are using Linux…wait a minute, why am i not using linux!?!誠然,這是如果您正在使用Linux的…且慢,為什麼我沒有使用Linux ! ? !
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克雷格