JENKINS timing tasks + automatic backup of sh database

1. Configure SVN\GIT code base

2. The jenkins configuration is executed at one o'clock in the morning every day (the time is automatically allocated)

3. Configure the build script (enter the working directory, empower, execute)

The start.sh script is as follows:

#!/bin/bash
# 运行pythonf程序
python3 -u XX.py

# 数据库认证
 user=""
 password=""
 host=""
 db_name=""
# 其它
 backup_path="/home/.jenkins/workspace/jira_daily/dbbackup"  # 备份地址
 date=$(date +"%d-%b-%Y")
# 设置导出文件的缺省权限
 umask 177
# Dump数据库到SQL文件
 mysqldump --user=$user --password=$password --host=$host $db_name > $backup_path/$db_name-$date.sql

# 删除7天之前的备份文件
find $backup_path/* -mtime +7 -exec rm {} \;

Guess you like

Origin blog.csdn.net/kk_gods/article/details/109054228