Как сделать резервную копию 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 {} \;


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

  1. When I originally commented I clicked the -Inform me when new remarks are included- checkbox as well as currently each time a remark is included I get four emails with the exact same remark. Is there any way you can remove me from that service? Thanks!

  2. Aw, this was a truly nice blog post. In suggestion I wish to put in composing similar to this furthermore? requiring time and also actual initiative to make a very good write-up? however what can I state? I procrastinate alot and never appear to obtain something done.

  3. The next time I read a blog site, I hope that it doesn’t dissatisfy me as much as this one. I suggest, I understand it was my option to read, however I actually thought youd have something interesting to claim. All I listen to is a lot of whimpering regarding something that you might fix if you werent as well active trying to find attention.

  4. Can I just say what a relief to discover someone that really understands what theyre talking about on the internet. You most definitely recognize just how to bring a problem to light as well as make it essential. Even more individuals require to read this as well as comprehend this side of the tale. I angle think youre not more prominent due to the fact that you most definitely have the gift.

  5. An excellent share, I simply offered this onto a coworker who was doing a little evaluation on this. And he actually acquired me breakfast since I located it for him. smile. So let me reword that: Thnx for the reward! But yeah Thnkx for investing the moment to review this, I really feel highly about it and also love reading more on this topic. Preferably, as you end up being expertise, would you mind updating your blog site with more details? It is very handy for me. Big thumb up for this article!

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

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