摘要:上面是備份的結果,注意,備份完了之后是壓縮包的形式,所以請你先安裝壓縮工具,不會的還是麻煩百度下,實在簡單成狗了。
前幾篇博客已經相繼公開了去轉盤網的所有技術細節,如下:
百度網盤爬蟲
中文分詞算法
邀請好友注冊
js分頁部分代碼
這篇博客我將繼續公開數據庫自動備份的代碼。可以這么說,沒有數據庫,一切就是個蛋,沒有數據庫備份,一切還是個蛋,你可以想象數據庫備份多么重要。不會linux,不會寫shell的朋友麻煩先去補補。不過你說我牛逼,不補也能看懂,那沒問題,哈哈,廢話不說了。老規矩,上代碼:
#!/bin/bash time=$(date +"%d-%m-%Y") pre=/home/ubuntu #想放到那里麻煩自己配置下哈 if [ ! -d "$pre/data_backup/$time" ] then mkdir -p $pre/data_backup/$time echo "create $pre/data_backup/$time" else echo "exist $pre/data_backup/$time" fi if [ -d "$pre/data_backup/$time" ] then mysqldump -h10.66.102.75 -uroot -p123456 --opt winrun user > $pre/data_backup/$time/user.sql mysqldump -h10.66.102.75 -uroot -p123456--opt winrun CategoryInfo > $pre/data_backup/$time/CategoryInfo.sql mysqldump -h10.66.102.75 -uroot -p123456 --opt winrun admin_info > $pre/data_backup/$time/admin_info.sql mysqldump -h10.66.102.75 -uroot -p123456 --opt winrun admin_loginfo > $pre/data_backup/$time/admin_loginfo.sql mysqldump -h10.66.102.75 -uroot -p123456 --opt winrun admin_notice_info > $pre/data_backup/$time/admin_notice_info.sql mysqldump -h10.66.102.75 -uroot -p123456--opt winrun advertising_info > $pre/data_backup/$time/advertising_info.sql mysqldump -h10.66.102.75 -uroot -p123456--opt winrun ajax_request_info > $pre/data_backup/$time/ajax_request_info.sql mysqldump -h10.66.102.75 -uroot -p123456 --opt winrun bt_file_info > $pre/data_backup/$time/bt_file_info.sql echo "backup finished" cd $pre/data_backup #enter dir zip -r $time.zip $time/ rm -fr $time #delete cd - echo "zip backup database finished" else echo "can not find backup file" fi
注意,我的密碼我已經改了,這個不能告訴你們,所以喜歡copy的孩子麻煩自己該密碼。下面我教大家玩下crotab,代碼如下:
# Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use "*" in these fields (for "any").# # Notice that tasks will be started based on the cron"s system # daemon"s notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command 10 1 * * 1,3,5 /home/backup.sh >> /home/backup.log
有用的是最下面的這一句,看到沒有,備份完了還得有個log,不然誰知道備份成什么樣子了,一點都不懂crontab麻煩自己百度下,我也一時給你講不明白。
上面是備份的結果,注意,備份完了之后是壓縮包的形式,所以請你先安裝壓縮工具,apt-get install XXXX 不會的還是麻煩百度下,實在簡單成狗了。
技術在于分享,開源,去轉盤不吝嗇任何技術,歡迎關注微博或者微信,隨時交流。本人建立個qq群作為去轉盤網的官方群,人數現在也不多,如果有興趣的話來逛逛吧,多個粉絲去轉盤多一份熱鬧,qq群號:512245829
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/17553.html
閱讀 3304·2021-11-18 10:02
閱讀 2751·2019-08-30 13:56
閱讀 407·2019-08-29 12:36
閱讀 521·2019-08-28 18:07
閱讀 712·2019-08-27 10:51
閱讀 3449·2019-08-26 12:13
閱讀 3286·2019-08-26 11:46
閱讀 3315·2019-08-23 12:00