backupMysql.sh
#!/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的更多相关文章
- backup-mysql.sh
#!/bin/bash#auto backup mariadb#xuegod 2015-12-30#Define PATH 定义变量date=`date +%Y-%m-%d`BAKDIR=" ...
- 1122Shell脚本之利用mysqldump备份MySQL数据库
#!/bin/bash #Mysql 自动备份 压缩并上传到 指定ftp #设想每天凌晨3点备份mysql #编辑crontab配置文件 #00 03 * * * backupmysql.sh #压缩 ...
- mysql自动备份维护shell脚本 (copy)
#!/bin/bash #Mysql 自动备份 压缩并上传到 指定ftp #设想每天凌晨3点备份mysql #编辑crontab配置文件 # * * * backupmysql.sh #压缩并以&qu ...
- (转)CentOS 7 下 MySQL 5.7 配置 Percona Xtrabackup
CentOS 7 下 MySQL 5.7 配置 Percona Xtrabackup 原文:http://qizhanming.com/blog/2017/05/10/install-percona- ...
- Linux下MySQL定时按日期备份数据
一.使用mysql内置命令 mysqldump Usage: mysqldump [OPTIONS] database [tables] mysqldump [OPTIONS] --databases ...
- mysql使用crontab定时备份
1, 安装crontab yum install vixie-cron yum install crontabs 说明:vixie-cron软件包是cron的主程序:crontabs软件包是用来安装. ...
- Mysql:自动化备份
简介 在这个数据为王的时代,数据的备份十分重要,这里就分享一篇mysql数据库自动备份的脚本(是从网上搜到的),其将配置文件和备份脚本分离,提高了安全性,脚本风格规范严谨,分享给大家希望对需要的小伙伴 ...
- centos8上使用crond
一,查看crond的状态: [root@yjweb crontab]# systemctl status crond 说明:和其他service的执行相同: 启动:systemctl start cr ...
- Centos定时备份 MySQL数据库
一.编写数据库备份脚本 backupmysql.sh #!/bin/bash # Name:bakmysql.sh # This is a ShellScript For Auto DB Backup ...
随机推荐
- ssm工程集成mybatis分页插件pagehelper
1 首先需要在mybatis的配置文件SqlMapConfig.xml文件中配置pagehelper插件 <plugins> <plugin interceptor=" ...
- MVVMLight 1:MVVMLight介绍以及在项目中的使用
一.MVVM 和 MVVMLight介绍 MVVM是Model-View-ViewModel的简写.类似于目前比较流行的MVC.MVP设计模式,主要目的是为了分离视图(View)和模型(Model)的 ...
- mongodb 聚合查询
操作符介绍: $project:包含.排除.重命名和显示字段 $match:查询,需要同find()一样的参数 $limit:限制结果数量 $skip:忽略结果的数量 $sort:按照给定的字段排序结 ...
- web前端性能优化总结
网站的划分一般为二:前端和后台.我们可以理解成后台是用来实现网站的功能的,比如:实现用户注册,用户能够为文章发表评论等等.而前端呢?其实应该是属于功能的表现.并且影响用户访问体验的绝大部分来自前端页面 ...
- 信息学奥赛一本通算法(C++版)基础算法:高精度计算
高精度加法(大位相加) #include <bits/stdc++.h> using namespace std; int main() { ],b1[]; ],b[],c[];//a,b ...
- 51Nod 1632 B君的连通(递归,快速幂)
1632 B君的连通 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 B国拥有n个城市,其交通系统呈树状结构,即任意两个城市存在且仅存在一条交通线将其连接.A国是B ...
- CodeForces731-C.Socks-并查集
C. Socks time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...
- JS 监听浏览器各个标签间的切换
以前看到过一些网页,在标签切换到其它地址时,网页上的标题上会发生变化,一直不知道这个是怎么做的,最近查了一些资料才发现有一个 visibilitychange 事件就可以搞定,这里将介绍一下页面可见性 ...
- [UWP]使用Acrylic
1. 前言 在 如何使用Fluent Design System 这篇文章里已经简单介绍过Reveal的用法,这篇再详细介绍其它内容. 自Windows 8 放弃Aero后,群众对毛玻璃回归的呼声一致 ...
- 怎么去掉织梦网站首页带的index.html/index.php
方法1. 1)在空间面板里面找到默认首页设置: 我们是需要去掉index.html,这时我们只需要把index.html这个把它移到最顶级去就行,然后点击确定,在打开网站刷新下,就基本可以解决了! 其 ...