Automatically pack MySQL under Binlog log

Source: Internet
Author: User

First, the demand

A machine on the line did rsync, pulling binlog logs from 5 MySQL machines to local, before manually packing, now writing a script, putting the crontab on regular packaging, and deleting the packaged files.


Second, the script is as follows

#!/bin/sh# usage: # nohup sh /tmp/backup_binlog_tar.sh > nohup.out   2>/dev/null  &dir_backup_tar= "/data0/backup_log-bin_tar" _ ' Date +%Y-%m-%d--%H-%M-%S ' echo  $dir _backup_tarmkdir -p  $dir _backup_tar#!/bin/sh# usage: # nohup sh  /tmp/backup_binlog_tar.sh > nohup.out  2>/dev/null  &dir_backup_ Tar= "/data0/backup_log-bin_tar" _ ' date +%y-%m-%d--%h-%m-%s ' echo  $dir _backup_tarmkdir -p $ dir_backup_tardir_binlog_140= "/data0/backup_log-bin/140/log-bin" dir_binlog_141= "/data0/backup_log-bin/141/ Log-bin "dir_binlog_145="/data0/backup_log-bin/145/log-bin "dir_binlog_146="/data0/backup_log-bin/146/log-bin " Dir_binlog_182= "/data0/backup_log-bin/182/log-bin" instance_seq=140dir_binlog= $dir _binlog_140if [ !  -d  $dir _binlog ]; then        echo  "$dir _ Binlog is not exit and skip! "  fifor instance in  ' ls  $dir _binlog ' do         cd  $dir _binlog        tar -zcf  $dir _backup_tar/"$ Instance_seq "" _ "" $instance "". tar.gz "  $instance         if [  $? -eq 0 ];then                 echo  "delete  $dir _binlog/$instance/*&nbsp ..."                  rm -rf  $dir _binlog/$instance/*         else                 echo  "tar  $dir _binlog/$instance  failed!!!"         fidoneinstance_seq=141dir_binlog= $dir _binlog_141if [  ! -d  $dir _binlog ]; then        echo  "$dir _binlog  is not exit and skip! "  fifor instance in  ' ls  $dir _binlog ' do         cd  $dir _binlog        tar -zcf  $dir _backup_tar/"$ Instance_seq "" _ "" $instance "". tar.gz "  $instance         if [  $? -eq 0 ];then                 echo  "delete  $dir _binlog/$instance/*&nbsp ..."                  rm -rf  $dir _binlog/$instance/*         else                 echo  "tar  $dir _binlog/$instance  failed!!!"         fidoneinstance_seq=145dir_binlog= $dir _binlog_145if [  ! -d  $dir _binlog ]; then        echo  "$ dir_binlog is not exit and skip! "  fifor instance in  ' ls  $dir _binlog ' do         cd  $dir _binlog        tar -zcf  $dir _backup_tar/"$ Instance_seq "" _ "" $instance "". tar.gz "  $instance         if [  $? -eq 0 ];then                 echo  "delete  $dir _binlog/$instance/*&nbsp ..."                  rm -rf  $dir _binlog/$instance/*         else                echo  "tar  $dir _binlog/$ Instance failed!!! "         fidoneinstance_seq=146dir_binlog= $dir _binlog_146if [  ! -d  $dir _binlog ]; then        echo  "$ dir_binlog is not exit and skip! "  fifor instance in  ' ls  $dir _binlog ' do         cd  $dir _binlog        tar -zcf  $dir _backup_tar/"$ Instance_seq "" _ "" $instance "". tar.gz "  $instance         if [  $? -eq 0 ];then                 echo  "delete  $dir _binlog/$instance/*&nbsp ..."                  rm -rf  $dir _binlog/$instance/*        else                 echo  "tar  $dir _binlog/$instance  failed!!! "         fidoneinstance_seq=182dir_binlog= $dir _binlog_182if [  ! -d  $dir _binlog ]; then        echo  "$ dir_binlog is not exit and skip! "  fifor instance in  ' ls  $dir _binlog ' do         cd  $dir _binlog        tar -zcf  $dir _backup_tar/"$ Instance_seq "" _ "" $instance "". tar.gz "  $instance         if [  $? -eq 0 ];then                 echo  "Delete  $dir _binlog/$instance/*&nbsp ... "                 rm -rf  $dir _binlog/$instance/*         else                echo   "tar  $dir _binlog/$instance  failed!!!"         fidone


This article is from the "Scattered People" blog, please be sure to keep this source http://zouqingyun.blog.51cto.com/782246/1872665

Automatically pack MySQL under Binlog log

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.