#!/bin/sh
#!/bin/bash
function backup()
{
for i in $*
do
mysqldump -h$hostip -P$port -u$username -p$password -E -R $i >> $filelocation/$edate/DB_$i'_'$edate.sql
done
# echo $filelocation"records listed below:"
# echo `ls $filelocation`
for x in `ls $filelocation`
do echo "for" $x
if [ -d "$filelocation/$x" ];then
#echo $(date +%s -d $edate)
#echo $(date +%s -d $x)
time1=$(($(date +%s -d $edate) - $(date +%s -d $x)));
time1=$(($time1///))
echo "the dis is "$time1" days"
if [ $time1 -gt $dis ];then
#echo $dis '<' $time1
#echo 'delete dir '$x
`rm -rf $filelocation/$x`
# else
#echo $dis '>' $time1
#echo 'save dir' $x
fi
fi
done } username=root
password="password"
hostip=127.0.0.1
port=
filelocation=/home/jet/backup/mysql
edate=`date +%Y-%m-%d`
dis=
if [ ! -d $filelocation ]; then
`mkdir "$filelocation"`
fi
if [ ! -d "$filelocation/$edate" ];then
`mkdir "$filelocation/$edate"`
fi
backup datebase1 database2 database3

backupMysql.sh的更多相关文章

  1. backup-mysql.sh

    #!/bin/bash#auto backup mariadb#xuegod 2015-12-30#Define PATH 定义变量date=`date +%Y-%m-%d`BAKDIR=" ...

  2. 1122Shell脚本之利用mysqldump备份MySQL数据库

    #!/bin/bash #Mysql 自动备份 压缩并上传到 指定ftp #设想每天凌晨3点备份mysql #编辑crontab配置文件 #00 03 * * * backupmysql.sh #压缩 ...

  3. mysql自动备份维护shell脚本 (copy)

    #!/bin/bash #Mysql 自动备份 压缩并上传到 指定ftp #设想每天凌晨3点备份mysql #编辑crontab配置文件 # * * * backupmysql.sh #压缩并以&qu ...

  4. (转)CentOS 7 下 MySQL 5.7 配置 Percona Xtrabackup

    CentOS 7 下 MySQL 5.7 配置 Percona Xtrabackup 原文:http://qizhanming.com/blog/2017/05/10/install-percona- ...

  5. Linux下MySQL定时按日期备份数据

    一.使用mysql内置命令 mysqldump Usage: mysqldump [OPTIONS] database [tables] mysqldump [OPTIONS] --databases ...

  6. mysql使用crontab定时备份

    1, 安装crontab yum install vixie-cron yum install crontabs 说明:vixie-cron软件包是cron的主程序:crontabs软件包是用来安装. ...

  7. Mysql:自动化备份

    简介 在这个数据为王的时代,数据的备份十分重要,这里就分享一篇mysql数据库自动备份的脚本(是从网上搜到的),其将配置文件和备份脚本分离,提高了安全性,脚本风格规范严谨,分享给大家希望对需要的小伙伴 ...

  8. centos8上使用crond

    一,查看crond的状态: [root@yjweb crontab]# systemctl status crond 说明:和其他service的执行相同: 启动:systemctl start cr ...

  9. Centos定时备份 MySQL数据库

    一.编写数据库备份脚本 backupmysql.sh #!/bin/bash # Name:bakmysql.sh # This is a ShellScript For Auto DB Backup ...

随机推荐

  1. Spring+SpringMVC+MyBatis+easyUI整合优化篇

    优化篇 Spring+SpringMVC+MyBatis+easyUI整合优化篇(一)System.out.print与Log Spring+SpringMVC+MyBatis+easyUI整合优化篇 ...

  2. 从“思考”的角度来看如何成为一名优质的Java架构师

    导读: 架构师应不应该写代码 为什么别人的系统总是那么烂 成为架构师最困难的门槛是什么? 如何更高效的学习? 1.架构师应不应该写代码 合格的程序员对于明确分配的任务会完成的很好,但是大部分情况下&q ...

  3. deeplearning.ai 作业中的Python常用命令

    1. print大法 test = Hello World print ("test:" + test) 2. math和numpy的区别:math只对单个元素,numpy会bro ...

  4. Codeforces 791A Bear and Big Brother(暴力枚举,模拟)

    A. Bear and Big Brother time limit per test:1 second memory limit per test:256 megabytes input:stand ...

  5. [51nod1457]小K vs. 竹子

    小K的花园种着n颗竹子(竹子是一种茎部中空并且长得又高又快的热带植物).此时,花园中第i颗竹子的高度是hi米,并且在每天结束的时候它生长ai米. 实际上,小K十分讨厌这些竹子.他曾经试图去砍光它们,但 ...

  6. hdu_2089(数位dp)

    hdu_2089(数位dp) 标签: dp 我初次接触数位dp表面上看上去挺简单,但是仔细学还是要考虑很多细节的.wa了无数次,这里引入一个 很好地博客 #include<cstdio> ...

  7. WEB 小案例 -- 网上书城(一)

    距离上次写博客有两周了吧,最多的原因就是自己期末考试了,上课没听就只能在期末狠狠的复习了,毕竟已经挂科了.当然还是因为自己懒吧!!!废话不多说开始我们今天的正题,网上书城! 一. 新建数据表(MySQ ...

  8. 1.移植3.4内核-分析内核启动过程,重新分区,烧写jffs2文件系统

    1.在上章-移植uboot里.我们来分析下uboot是如何进入到内核的 首先,uboot启动内核是通过bootcmd命令行实现的,在我们之前移植的bootcmd命令行如下所示: bootcmd=nan ...

  9. Linux下安装PostgreSQL 转载linux社区

    Linux下安装PostgreSQL [日期:2016-12-25] 来源:Linux社区  作者:xiaojian [字体:大 中 小]   在Linux下安装PostgreSQL有二进制格式安装和 ...

  10. 关于layer的坑

    真是自己给自己挖坑,坑死人不偿命啊. 在用layui开发时,遇到这种情况,点击按钮出现一个弹出层,然而我不是用button按钮去实现的,而是用a标签做的,本来a标签也是可以实现的,在这里我无形中给自己 ...