springboot定时备份MYSQL_java代码定时备份mysql数据库及注意事项——基于 springboot...

git 拉取:https://gitee.com/kevin9401/BackUpDataBase.git一、需求:定时备份数据库数据二、分析:1. 定时任务2. 备份数据库表结构和数据三、实现:1. pom 文件:xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apach...
摘要由CSDN通过智能技术生成

git 拉取: https://gitee.com/kevin9401/BackUpDataBase.git

一、需求:

定时备份数据库数据

二、分析:

1. 定时任务

2. 备份数据库表结构和数据

三、实现:

1. pom 文件:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

org.springframework.boot

spring-boot-starter-parent

2.2.2.RELEASE

com.kevin

backupdatabase

1.0-SNAPSHOT

jar

1.8

mysql

mysql-connector-java

8.0.15

com.alibaba

druid

1.1.20

org.springframework.boot

spring-boot-starter

2.2.4.RELEASE

org.awaitility

awaitility

3.1.2

test

org.springframework.boot

spring-boot-maven-plugin

2. application.yml 文件

spring:

datasource:

driver-class-name: com.mysql.jdbc.Driver

url: jdbc:mysql://192.168.100.120:3306/test01?useSSL=false&autoReconnect=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8

username: kevin02

password: Kevin123!

sqlbackup:

path: /export/servers/db_backup/

3. BackUpDataBaseManager —— 具体操作数据库备份

package com.kevin.manager;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.stereotype.Service;

import java.io.File;

import java.io.IOException;

/**

* @a

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值