jira-备份文档

阅读量: zyh 2022-03-23 18:26:58
Categories: > Tags:

基本

系统备份均备份到本地磁盘,需自行写脚本备份到对象存储。

Jira备份Web配置

系统-服务,如果没有备份服务,则需要新加备份服务。

备份服务-类:com.atlassian.jira.service.services.export.ExportService

image-20220324110110748

💥这里的时间间隔是UTC+8,而我服务器时间是UTC+0

✨这个Jira的WEB备份不包含附件,附件需要自行脚本备份

Confluence备份Web配置

一般配置-预定作业-备份系统

image-20220324110436538

💥这里Cron表达式是UTC+0

将备份复制到S3

计划任务

#jira自动备份时间是 utc 11:00, 因此上传到s3定到11:15
15 11 * * * root /export/atlassian/application-data/jira/export/start > /export/atlassian/application-data/jira/export/start.log 2>&1

#jira confluence 自动备份时间是 utc0 12:00, 因此上传到S3定到13:00
00 13 * * * root /export/confluence_data/backups/start > /export/confluence_data/backups/start.log 2>&1

备份脚本

✨脚本应放在jira或者confluence_data的备份目录内,方式就是扫描目录里的已备份文件,通过文件名获取备份文件的时间,删除7天之前的备份,然后同步到s3

/export/atlassian/application-data/jira/export/start

#!/bin/bash
export AWS_DEFAULT_REGION='cn-north-1'
basedir=`cd "$(dirname "$0")"; pwd`
BucketName=''
BucketPath='backup/jira'

# 确定gitlab备份文件地址
cd ${basedir}
ls *.zip | while read line;do
        FileCTime=`echo ${line} | awk -F '.' '{gsub(/_/," ",$1);print $1}'`
        Old7day=`date -d "-7 days" "+%s"`
        FileCTimeStamp=`date -d "$FileCTime" +%s`
        if [ $FileCTimeStamp -lt $Old7day ];then
              [[ -f ${line} ]] && rm -rf ${line} && echo "Delete old7day file ${basedir}/${line}"
        fi
done

echo "Start: `date "+%Y%m%d %H%M%S"` --> s3://${BucketName}/${BucketPath}"
aws s3 sync ${basedir}/ s3://${BucketName}/${BucketPath}/ --delete --exclude '*.log'
echo "End: `date "+%Y%m%d %H%M%S"` --> oss://${BucketName}/${BucketPath}"

CurrentTime=`date +%Y%m%d`
cd ../data/attachments/ && touch ${CurrentTime}_attachments.tgz
tar --exclude=${CurrentTime}_attachments.tgz -zcvf ${CurrentTime}_attachments.tgz . && aws s3 cp ${CurrentTime}_attachments.tgz s3://${BucketName}/${BucketPath}/
rm -rf ${CurrentTime}_attachments.tgz

/export/confluence_data/backups/start

#!/bin/bash
export AWS_DEFAULT_REGION='cn-north-1'
basedir=`cd "$(dirname "$0")"; pwd`
BucketName=''
BucketPath='backup/jira_confluence'

# 确定gitlab备份文件地址
cd ${basedir}
ls *.zip | while read line;do
        FileCTime=`echo ${line} | awk -F"." '{print $1}' | awk -F"-" '{tmp=$2;gsub(/_/,"-",tmp);print tmp}'`
        Old7day=`date -d "-7 days" "+%s"`
        FileCTimeStamp=`date -d "$FileCTime" +%s`
        if [ $FileCTimeStamp -lt $Old7day ];then
              [[ -f ${line} ]] && rm -rf ${line} && echo "Delete old7day file ${basedir}/${line}"
        fi
done

echo "Start: `date "+%Y%m%d %H%M%S"` --> s3://${BucketName}/${BucketPath}"
aws s3 sync ${basedir}/ s3://${BucketName}/${BucketPath}/ --delete --exclude '*.log'
echo "End: `date "+%Y%m%d %H%M%S"` --> oss://${BucketName}/${BucketPath}"