Home > Database > Mysql Tutorial > mysql工具备份脚本

mysql工具备份脚本

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:14:29
Original
993 people have browsed it

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 今天写了一个mysql备份,主要用的是mysqldump工具。需求是每天3点备份某些数据库,保留2天的备份。很简单的需求,如下脚本 #!/bin/sh dbs=$(echo `/usr/bin/mysql -uroot -ppasswd -s -e "show datab

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  今天写了一个mysql备份,主要用的是mysqldump工具。需求是每天3点备份某些数据库,保留2天的备份。很简单的需求,如下脚本

  #!/bin/sh

  dbs=$(echo `/usr/bin/mysql -uroot -ppasswd -s -e "show databases;" |egrep -v "performance_schema|information_schema|test|mysql"`)

  bak_name=`hostname``date '+%Y%m%d%H%M'`

  /usr/bin/mysqldump -uroot -ppasswd --single-transaction --databases $dbs > /data/backup/$bak_name.sql && gzip /data/backup/$bak_name.sql

  /usr/bin/find /data/backup/ -type f -mtime +2 -exec  rm -f {} \;

  crontab设置定时

  0 3 * * * /bin/sh /root/script/backup.sh > /dev/null 2>&1

mysql工具备份脚本

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template