In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Previous blogs have published all the technical details of the turntable network, as follows:
Baidu disk crawler
Chinese word segmentation algorithm
Invite friends to register
Js paging part code
In this blog, I will continue to disclose the code for automatic database backup. It can be said that without database, everything is an egg, without database backup, everything is still an egg, you can imagine how important database backup is. Friends who can't linux, can't write shell, please go to make up first. But you say I'm good, and I can understand it even if I don't make up. That's no problem. Haha, stop talking nonsense. The old rule, go to the code:
#! / bin/bashtime=$ (date + "% d-%m-%Y") pre=/home/ubuntu # want to put it there, please configure 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" fiif [- d "$pre/data_backup/$time"] then mysqldump-h20.66.102.75-uroot- P123456--opt winrun user > $pre/data_backup/$time/user.sql mysqldump-h20.66.102.75-uroot-p123456--opt winrun CategoryInfo > $pre/data_backup/$time/CategoryInfo.sql mysqldump-h20.66.102.75-uroot-p123456--opt winrun admin_info > $pre/data_backup/$time/admin_info.sql mysqldump-h20.66.102.75-uroot-p123456--opt winrun admin_loginfo > $pre/data_backup/$time/admin_loginfo.sql mysqldump-h20. 66.102.75-uroot-p123456--opt winrun admin_notice_info > $pre/data_backup/$time/admin_notice_info.sql mysqldump-h20.66.102.75-uroot-p123456--opt winrun advertising_info > $pre/data_backup/$time/advertising_info.sql mysqldump-h20.66.102.75-uroot-p123456--opt winrun ajax_request_info > $pre/data_backup/$time/ajax_request_info.sql mysqldump-h20.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
Note that I have changed my password, and I can't tell you this, so children who like copy trouble themselves with the password. Next, I'll teach you how to play crotab. The code is as follows:
# 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 command10 1 * * 1 Magi 3 home/backup.sh > > / home/backup.log
Useful is the bottom of this sentence, see, there must be a log after the backup, otherwise who knows what the backup looks like, do not understand crontab trouble their own Baidu, I also temporarily do not understand to you.
The above is the backup results, note that after the backup is in the form of compression package, so please install the compression tool first, apt-get install XXXX will not or trouble Baidu, it is really simple to become a dog.
Technology lies in sharing, open source, go to the turntable is not stingy with any technology, welcome to follow Weibo or Wechat, feel free to communicate.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.