Jira和Confluence备份恢复

jira和confluence备份

备份脚本:

#! /bin/bash

echo "########################################"
  TIMESTAMP=$(date +"%F" -d "-1day")
#备份路径
  BACKUP_DIR="/data/backup/data"
  MYSQL_USER="root"
  MYSQL_HOST="127.0.0.1"
  MYSQL=/usr/bin/mysql
  MYSQL_PASSWORD="xxxxx"
  MYSQLDUMP=/usr/bin/mysqldump
  databases=`$MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASSWORD -N -e "SHOW DATABASES;" | grep -Ev "(information_schema|performance_schema|mysql|test)"`
  echo $databases

  [ ! -d "$BACKUP_DIR" ] && mkdir -p "$BACKUP_DIR"

for db in $databases; do
   $MYSQLDUMP -h$MYSQL_HOST --force --opt --single-transaction --master-data=2 -F -u$MYSQL_USER -p$MYSQL_PASSWORD --databases $db > "$BACKUP_DIR"/"$db".sql
done

#jira家目录
  jira_dir="/var/atlassian/application-data/jira/"
#confluence家目录
  confluence_dir="/var/atlassian/application-data/confluence"

#备份数据目录
  cd "$jira_dir" && tar czvf jira_data.tar.gz data caches >/dev/null
  cd "$confluence_dir" && tar czvf confluence_data.tar.gz confluence.cfg.xml attachments index >/dev/null
  cd "$BACKUP_DIR" && mv "$jira_dir"/jira_data.tar.gz . && mv "$confluence_dir"/confluence_data.tar.gz .
  zip -r jira_confluence_"$TIMESTAMP".zip *.sql jira_data.tar.gz confluence_data.tar.gz && rm *.sql jira_data.tar.gz confluence_data.tar.gz -f

#将备份的数据复制到S3桶
  cp jira_confluence_"$TIMESTAMP".zip /S3/jira/
  mv /var/atlassian/application-data/confluence/backups/confluence-`date +%F`.zip /S3/jira/

#保留七天数据
  /bin/find "$BACKUP_DIR" -mtime +7|xargs rm -f
echo "########################################"

备份恢复:

     1.将备份的数据目录进行替换 

     2.清空旧的数据库,导入备份的mysql数据

confluence另一种备份方式

在Confluence   General Configuration页面 点击 Backup Administration 添加备份配置

恢复:在General Configuration的 Backup & Restore  上传备份进行恢复 

参考链接:

https://confluence.atlassian.com/adminjiraserver072/backing-up-data-828788079.html  (jira)

https://confluence.atlassian.com/doc/site-backup-and-restore-163578.html  (confluence)

           

posted @ 2018-11-06 16:29  imcati  阅读(562)  评论(0编辑  收藏  举报