数据库:ubantu下MySQL数据库备份方法
1、编辑/etc/crontab文件设定定时任务,在制定时间执行backup_databases.sh
vi /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do. SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) 25 9 * * * root sh /home/autotest/backup_databases.sh
2、编写backup_databases.sh,内容如下:
#!/bin/bash
# Set the backup filename and directory
DATE=`date +%Y%m%d` # e.g 20101025
FILENAME="trunk_development_database_$DATE.sql";
BACKUPDIR="/backup/";
# Database Credentials
DBUSER="root";
DBPWD="123qwe^&*";
DBNAME="trunk_development";
# Change to the root directory
cd /
# Where is our gzip tool for compression?
# The -f parameter will make sure that gzip will
# overwrite existing files
GZIP="/bin/gzip -f";
# Delete old backups older than 3 days
find /backup/trunk_development_*gz -mtime +3 -exec rm {} \;
# execute the database dump
mysqldump --user=$DBUSER --password=$DBPWD --add-drop-table --databases $DBNAME > $BACKUPDIR$FILENAME
# compress the database backup$GZIP $BACKUPDIR$FILENAME
3、手动创建目录/backup
数据库:ubantu下MySQL数据库备份方法的更多相关文章
- linux下mysql定时备份数据库
linux下mysql定时备份数据库 (2010-10-21 12:40:17) 转载▼ 标签: 杂谈 一.用命令实现备份 首页进入mysql的bin目录 1.备份数据#mysqldump -uu ...
- Ubuntu Server下MySql数据库备份脚本代码
明: 我这里要把MySql数据库存放目录/var/lib/mysql下面的pw85数据库备份到/home/mysql_data里面,并且保存为mysqldata_bak_2012_04_11.tar. ...
- ubuntu 下 mysql数据库的搭建 及 数据迁移
1.mysql的安装 我是使用apt-get直接安装的 :sudo apt-get install mysql-server sudo apt-get install mysql-client 2.配 ...
- 解决Linux系统下Mysql数据库中文显示成问号的问题
当我们将开发好的javaWEB项目部署到linux系统上,操作数据库的时候,会出现中文乱码问题,比如做插入操作,发现添加到数据库的数据中文出现论码,下面就将解决linux下mysql中文乱码问题! 打 ...
- Linux系统下 MYSQL数据库中的数据库文件在本机内迁移 (需暂停服务的方式)
Linux系统下 MYSQL数据库中的数据库文件在本机内迁移 本机采用Ubuntu16.04系统,tar方式安装MySQL5.7.21 数据库安装文件夹为 /home/devil/mysql 现 ...
- Linux下MySQL数据库主从同步配置
说明: 操作系统:CentOS 5.x 64位 MySQL数据库版本:mysql-5.5.35 MySQL主服务器:192.168.21.128 MySQL从服务器:192.168.21.129 准备 ...
- wamp集成环境下mysql数据库的分开部署和远程访问
今天折腾了一天一个小问题,就是明明正确的php代码在访问数据库的时候总是提示DB ERROR.后来才发现是填写数据库名的时候,写成了该数据库的ip地址(其实也是本机ip但是本机还是不能访问),而不是l ...
- Linux学习之CentOS(一)--CentOS6.6下Mysql数据库的安装与配置
在这里我是通过yum来进行mysql数据库的安装的,通过这种方式进行安装,可以将跟mysql相关的一些服务.jar包都给我们安装好,所以省去了很多不必要的麻烦!!! [root@larry ~]# c ...
- Linux下MySQL数据库的备份与恢复
Linux下MySQL数据库的备份与恢复 作者:Grey 原文地址: Github 语雀 博客园 基于版本 MySQL5.7 Deepin Linux 15.11 xtrabackup-2.4.18 ...
随机推荐
- CodeWars上的JavaScript技巧积累
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice The sli ...
- 用简单的反射优化代码(动态web项目)
在动态web项目中,没有使用框架时,只是简单的jsp访问servlet实现增删改查, 无论是哪个方法都需要经过Servlet中的doGet()方法或doPost()方法,我们可以在链接中附带参数进行区 ...
- hive学习2(Navicat连接hive)
Navicat连接hive 第一步:win下安装好mysql 第二步:win下安装Navicat 第三步:启动hadoop集群,启动hive 第四步:Navicat连接hive 在第四步中需先配置ss ...
- JavaWeb -- Servlet Filter 过滤器
1. Servlet API中提供了一个Filter接口,开发web应用时,如果编写的Java类实现了这个接口,则把这个java类称之为过滤器Filter.通过Filter技术,开发人员可以实现用户在 ...
- 如何编写 Makefile
1. 目标 依赖 命令 make会比较targets文件和prerequisites文件的修改日期,如果prerequisites文件的日期要比targets文件的日期要新,或者target不存在的 ...
- select2 使用
<link href="/plugin/select2/css/select2.min.css" rel="stylesheet" /> <s ...
- Neutron新进展|DragonFlow在Mitaka版本中的Roadmap
OpenStack网络在Mitaka版本中将有哪些新变化?1月11日到12日,DragonFlow的PTL——Eran Gampel,Kuryr的PTL——Gal Sagie,和他们的老大从以色列来到 ...
- alias 中使用awk
alias hehistory10='history |awk "{print \$2}"|sort|uniq -c|sort -rn|head -10' $要转义
- 如何在windows上部署war包到tomcat服务器
一. 什么是war包 WAR(Web Archive file)网络应用程序文件,是与平台无关的文件格式,它允许将很多文件组合成一个压缩文件.war专用在web方面,一个war包可以理解为一个web项 ...
- ural 2013 Neither shaken nor stirred
2013. Neither shaken nor stirred Time limit: 1.0 secondMemory limit: 64 MB The ACM ICPC regional con ...