Mysql数据有多珍贵大家都知道,如果有一天辛辛苦苦写的博客文章突然间不能用了,数据又没备份,那真是死的心都有
,记录一下Mysql数据库备份的脚本,这个脚本的功能是自动进行滚动备份,也就是自动记录一周的备份,超过一周将无法恢复,
希望对大家有帮助:
1.首先是备份方法 在任意目录中创建一个sh脚本文件, vi /usr/back.sh 写入以下语句: mysql_user="root" #你的数据库管理员用户名 mysql_passwd="root" #你的数据库管理员密码 base_name="db_any" #要备份的库名 dir="/usr/backup/sqlbackup" #备份保存路径,注意必须先建立好路径,否则报错 timestamp="$(date +"%w")" #添加备份时间戳 ,此处是获取星期的数字 mysqldump -u$mysql_user -p$mysql_passwd $base_name > "$dir/$base_name"_"$timestamp.sql" 然后添加自动定时运行 crontab –e #编辑一下命令 00 3 * * * sh /usr/back.sh #表示每天凌晨3点钟运行一次备份命令, 这样指定时间就会自己备份了,然后自动覆盖上周同一星期数的,这样就循环覆盖,始终保持过去1周的备份. 2.如何恢复 如果你的备份为db_2017.sql,要恢复的库名为tempdb,则运行以下命令 mysql -hlocalhost -uroot -proot tempdb < db_2017.sql
cost of is is
4d97 compra is ato mexico
4d97 how to be is usa
4d97 getting is in vancouver
4d97
mail order is sublingual
99a2
A classic and well worth the investment. Wear it for life and then pass it on.
Nice blog here! Also your site loads up very fast!
What web host are you using? Can I get your affiliate link to your host?
I wish my web site loaded up as fast as yours lol
After I initially commented I appear to have clicked on the -Notify me when new comments are added-
checkbox and now every time a comment is added I get four emails with the exact same comment.
Perhaps there is a way you can remove me from that service?
Many thanks!
Good day! Do you know if they make any plugins to protect
against hackers? I’m kinda paranoid about losing everything I’ve worked
hard on. Any recommendations?
Simply wish to say your article is as astounding.
The clearness to your post is just great and i could think you’re
an expert on this subject. Fine together with your permission let me to
snatch your RSS feed to stay up to date with drawing close post.
Thank you a million and please continue the gratifying work.
If some one wants expert view concerning blogging and site-building afterward i recommend him/her to pay a visit
this weblog, Keep up the good job.
Hello, constantly i used to check blog posts here early in the dawn, because
i enjoy to find out more and more.