脚本-每3天对数据库目录/var/lib/mysql做物理备份 把数据备份到系统/opt/dbbak目录

每3天对数据库目录/var/lib/mysql做物理备份 把数据备份到系统/opt/dbbak目录

#!/bin/bash

DAY=`date+%Y-%m-%d`

SIZE=`du-sh /var/lib/mysql`

cd/opt/dbbak  2> /dev/null  || mkdir /opt/dbbak

echo"Date: $DAY" > /opt/dbbak/dbinfo.txt

echo"Total Database Size: $SIZE" >> /opt/dbbak/dbinfo.txt

tar-zcf  /opt/dbbak/mysqlbak-${DAY}.tgz/var/lib/mysql /opt/dbbak/dbinfo.txt  &>/dev/null

rm-rf /opt/dbbak/dbinfo.txt

:wq

 

chmod+x  /shell/mysqlbak.sh

 

crontab  -e

30   23  */3   *   *   /shell/mysqlbak.sh

 

service  cornd start

 

 

2#!/bin/bash

cp-a  /var/lib/mysql   /tmp/backup/`date +%F%H%M`

3

2

[root@localhost桌面]# chmoda+x/myslbk.sh

 [root@localhost 桌面]# cat /myslbk.sh

#!/bin/bash

tarpzcfP  /tmp/sqlbak/mysql-`date +%F%H%M`.tar.gz/var/lib/mysql

[root@localhost桌面]# crontab -l

** */3 * *  tarpzcfP  /myslbk.sh

 

#!/bin/bash

DAY=`date+%F`

SIZE=`du  -sh /var/lib/mysql/`

bakdir=/opt/dbbak

cd$bakdir ||  mkdir      $bakdir

echo  ""

tar -zcvf  dbbak-${DAY}.tar.gz  /var/lib/mysql/*


脚本-每3天对数据库目录/var/lib/mysql做物理备份 把数据备份到系统/opt/dbbak目录

上一篇:MySQL高级查询(一)


下一篇:mysql的GUI工具