Как сделать резервную копию MySql всех баз данных

Хочу поделится с вами небольшим скриптом для создания резервных копий всех баз данных MySql.



MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"


CHOWN="$(which chown)"
CHMOD="$(which chmod)"
GZIP="$(which gzip)"


NOW="$(date +"%Y%m%d")"


# DO NOT BACKUP these databases, delemiter SPACE

# Get all database list first
DBS="$($MYSQL -u $MyUSER -h $MyHOST -p$MyPASS -Bse 'show databases')"

for db in $DBS

    if [ "$IGN" != "" ]; then
        for i in $IGN
            [ "$db" == "$i" ] && skipdb=1 || :

    if [ "$skipdb" == "-1" ] ; then
        [ ! -d $MBD ] && mkdir -p $MBD || :
            $MYSQLDUMP --opt -u $MyUSER -h $MyHOST -p$MyPASS $db | $GZIP -9 > $FILE
        FNUM="$(find $MBD/* | wc -l)"
        if [ $FNUM -ge 0 ] ; then
            find $MBD/* -type f -mtime 20 -exec rm -rf {} \;

Рекомендуем почитать
Чистим историю в базе данных zabbix

Ни для кого не секрет , что со временем база данных zabbix увеличивается. Поэтому покажу вам как ее почистить в Читать дальше...

Узнать размеры всех баз mysql

SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB", sum( Читать дальше...

Выводим список таблиц с количеством записей в mysql

Хочу привести небольшой пример запроса, с помощью которого можно получить список таблиц в mysql базе с количеством записей : SELECT Читать дальше...

Speedtest из командной строки Linux

Часто бывает необходимо проверить скорость интернет соединения на серверах Linux. И самый лучший, на мой взгляд, сервис для этого speedtest.net. Читать дальше...


42 комментария к “Как сделать резервную копию MySql всех баз данных

  1. I just want to mention I am newbie to blogging and seriously savored your web blog. Most likely I’m likely to bookmark your blog . You definitely have terrific articles and reviews. Appreciate it for sharing with us your website page.

  2. Please let me know if you’re looking for a article writer for your weblog. You have some really good posts and I feel I would be a good asset. If you ever want to take some of the load off, I’d absolutely love to write some material for your blog in exchange for a link back to mine. Please send me an e-mail if interested. Cheers!

  3. Nice blog post. I discover something extra tough on different blogs everyday. It will certainly constantly be stimulating to check out web content from other authors and also exercise a something from their shop. I?d choose to make use of some with the web content on my blog whether you don?t mind. Natually I?ll provide you a web link on your web blog. Thanks for sharing.

  4. I?m pleased, I have to say. Truly rarely do I run into a blog that?s both enlightening and entertaining, and let me inform you, you have struck the nail on the head. Your suggestion is exceptional; the concern is something that not nearly enough people are talking wisely about. I am really happy that I stumbled across this in my search for something connecting to this.

  5. A remarkable share, I simply provided this onto a colleague that was doing a little analysis on this. And also he in fact got me breakfast due to the fact that I discovered it for him. smile. So let me reword that: Thnx for the reward! But yeah Thnkx for spending the time to review this, I feel highly concerning it as well as like learning more on this subject. Ideally, as you become knowledge, would certainly you mind updating your blog site with even more details? It is extremely valuable for me. Large thumb up for this article!

  6. I found your blog website on google and also inspect a few of your very early messages. Continue to keep up the very good run. I simply extra up your RSS feed to my MSN News Visitor. Looking for ahead to learning more from you in the future!?

  7. I was really pleased to locate this web-site. I wished to thanks for your time for this wonderful read!! I certainly delighting in every little bit of it as well as I have you bookmarked to check out new things you post.

  8. A fascinating discussion is worth remark. I think that you must compose much more on this subject, it may not be a taboo subject however typically individuals are not nearly enough to speak on such topics. To the following. Thanks

  9. Good post. I find out something more challenging on different blog sites daily. It will certainly constantly be promoting to read web content from various other authors as well as exercise a something from their shop. I?d prefer to utilize some with the content on my blog whether you don?t mind. Natually I?ll provide you a link on your internet blog site. Thanks for sharing.

  10. After research a few of the article on your site now, as well as I truly like your way of blog writing. I bookmarked it to my book mark site checklist and will be inspecting back quickly. Pls look into my web site as well and let me understand what you think.

  11. I uncovered your blog website on google as well as examine a few of your very early messages. Remain to keep up the very good operate. I just extra up your RSS feed to my MSN News Reader. Looking for ahead to learning more from you later!?

  12. Oh my benefits! an incredible post man. Thanks However I am experiencing issue with ur rss. Don?t know why Unable to register for it. Is there any individual obtaining the same rss problem? Any person that knows kindly respond. Thnkx

  13. The next time I review a blog site, I really hope that it does not disappoint me as long as this. I imply, I understand it was my choice to check out, but I actually assumed youd have something fascinating to state. All I hear is a bunch of whimpering concerning something that you might repair if you werent too active searching for focus.

  14. Hey! Someone in my Myspace group shared this site with us so I came to look it over. I’m definitely enjoying the information. I’m book-marking and will be tweeting this to my followers! Exceptional blog and wonderful design.

  15. Aw, this was an actually great article. In concept I wish to put in creating similar to this additionally? taking time and also actual initiative to make a very good post? yet what can I state? I hesitate alot as well as never appear to obtain something done.

  16. Whats up this is kinda of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding know-how so I wanted to get advice from someone with experience. Any help would be enormously appreciated!

  17. I am typically to blogging as well as i actually appreciate your content. The write-up has really peaks my interest. I am going to bookmark your site and also keep checking for new information.

  18. There are some fascinating points in time in this short article yet I don?t know if I see every one of them center to heart. There is some legitimacy however I will hold opinion up until I look into it better. Good article, many thanks and we want extra! Contributed to FeedBurner too

  19. There are some intriguing points in time in this short article but I don?t understand if I see all of them center to heart. There is some credibility however I will hold viewpoint till I check into it even more. Excellent article, many thanks and also we desire a lot more! Included in FeedBurner as well

Оставить ответ

Ваш адрес email не будет опубликован. Обязательные поля помечены *