一、Dashboard 界面备份与还原
1.备份
#1.以管理员身份登录,点击设-->一般设置-->备份与还原
#2.点击导出,包含附件,看到导出的文件在/var/atlassian/confluence/temp/xmlexport-20210531-174454-1.zip里面。
2.还原
#1.以管理员身份登录,点击设-->一般设置-->备份与还原
可以看到:
1.当数据大小小于25M的时候,直接下载文件导入;
2.当数据大小大于25M的时候,需要将文件放在/var/atlassian/confluence/restore 中
#2.拷贝原数据
[root@staging confluence]# cd /var/atlassian/application-data/confluence/backups/
[root@staging backups]# ll
total 77636
-rw------- 1 confluence1 root 79497147 Jan 7 02:37 backup-2021_01_07.zip
#查看原数据大小
[root@staging backups]# du -sh backup-2021_01_07.zip
76M backup-2021_01_07.zip
[root@staging backups]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e7b46899bb75 confluence:latest "/docker-entrypoin..." 3 days ago Up 2 hours 0.0.0.0:8090-8091->8090-8091/tcp confluence
[root@staging backups]# docker cp /var/atlassian/application-data/confluence/backups/backup-2021_01_07.zip e7b46899bb75:/var/atlassian/confluence/restore
#3.刷新页面,发现下面多了原数据文件,选择这个文件,点击导入
#4.等待导入成功,刷新页面,用原数据的管理员账号密码登录
#5.登录成功后发现之前的数据已经出现了,至此confluence备份还原结束。
二、Linux命令行备份Confluence
1.备份
1)拷贝Confluence安装目录
#1.创建Confluence备份目录
[root@staging ~]# mkdir confluence_bak
#2.复制Confluence安装目录到该目录下
[root@staging ~]# cp -a /opt/atlassian confluence_bak/
#3.查看Confluence备份目录
[root@staging ~]# ll confluence_bak/
total 0
drwxr-xr-x 3 root root 24 May 27 2019 atlassian
2)拷贝Confluence Home目录
Confluence Home目录在文件Confluence安装目录/opt/atlassian/confluence/confluence/WEB-INF/classes/confluence-init.properties中由confluence.home配置。
#1.查找Confluence Home目录的位置
[root@staging ~]# cat /opt/atlassian/confluence/confluence/WEB-INF/classes/confluence-init.properties
# This file allows you to set the directory for Confluence to store its configuration files.
#
###########################
# Note for Windows Users #
###########################
#
# Each backslash in your path must be written as a forward slash.
# - For example:
# c:confluencedata
#
# should be written as:
#
# c:/confluence/data
###########################
# Note for Unix Users #
###########################
# - For example:
# confluence.home=/var/confluence
#
# NOTE: If the path of your confluence.home directory contains symlinks,
# please set confluence.home to the absolute path, otherwise problems may occur.
# - For example:
# confluence.home=/data/confluence/ (where /data is a symlink to -> /var/data/)
# should be written as:
# confluence.home=/var/data/confluence/
###########################
# Configuration Directory #
###########################
# specify your directory below (don't forget to remove the '#' in front)
# confluence.home = /var/atlassian/application-data/confluence
confluence.home=/data3/atlassian/application-data/confluence/
#2.拷贝Confluence数据目录
[root@staging ~]# cp -a /data3/atlassian/application-data/ confluence_bak/atlassian/
3)拷贝Confluence备份目录
#1.打包Confluence备份目录
[root@staging ~]# tar czf confluence.tar.gz confluence_bak
#2.下载压缩包上传到新的服务器上
[root@staging ~]# sz confluence.tar.gz
[root@staging ~]# rz
#3.解压压缩包
[root@staging ~]# tar xf confluence.tar.gz
#4.拷贝目录到相应的目录下
[root@staging ~]# mkdir /opt/atlassian
[root@staging ~]# cp -a confluence_bak/atlassian/confluence /opt/atlassian
[root@staging ~]# cp confluence_bak/atlassian/application-data /data3
4)导出原服务器上的数据库
# 原服务器上的数据库是confluence
[root@staging ~]# mysqldump -uroot -p confluence > confluence.sql
# 下载confluence备份数据
[root@staging ~]# sz confluence.sql
2.还原
1)新服务器上创建数据库并导入数据
#1.上传confluence备份数据
[root@staging ~]# rz
#2.进入数据库
[root@staging ~]# mysql -u root -p
#3.创建数据库并导入备份数据
mysql> CREATE DATABASE IF NOT EXISTS confluence DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
mysql> use confluence;
mysql> source /root/confluence.sql; #注意,这里需要写入confluence.sql的绝对路径
2)修改Confluence Home配置文件
修改hibernate.connection.url的value为新的数据库地址
[root@staging ~]# vim /data3/atlassian/application-data/confluence/confluence.cfg.xml
3)启动Confluence
[root@staging lib]# cd /opt/atlassian/confluence/bin
[root@staging bin]# ./start-confluence.sh
4)验证服务
[root@staging bin]# ps -ef |grep confluence
conflue+ 22529 1 99 18:34 ? 00:02:35 /opt/atlassian/confluence/jre//bin/java -Djava.util.logging.config.file=/opt/atlassian/confluence/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Xms256m -Xmx2048m -XX:PermSize=128m -XX:MaxPermSize=512m -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dconfluence.context.path= -Datlassian.plugins.startup.options= -Dorg.apache.tomcat.websocket.DEFAULT_BUFFER_SIZE=32768 -Dsynchrony.enable.xhr.fallback=true -Xms1024m -Xmx1024m -XX:+UseG1GC -Datlassian.plugins.enable.wait=300 -Djava.awt.headless=true -XX:G1ReservePercent=20 -Xloggc:/opt/atlassian/confluence/logs/gc-2021-05-26_18-34-57.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2M -XX:-PrintGCDetails -XX:+PrintGCDateStamps -XX:-PrintTenuringDistribution -Dignore.endorsed.dirs= -classpath /opt/atlassian/confluence/bin/bootstrap.jar:/opt/atlassian/confluence/bin/tomcat-juli.jar -Dcatalina.base=/opt/atlassian/confluence -Dcatalina.home=/opt/atlassian/confluence -Djava.io.tmpdir=/opt/atlassian/confluence/temp org.apache.catalina.startup.Bootstrap start
conflue+ 23320 22529 28 18:35 ? 00:00:14 /opt/atlassian/confluence/jre/bin/java -classpath /opt/atlassian/confluence/temp/2.1.0-release-confluence_6.5-1a01ab2d.jar:/opt/atlassian/confluence/confluence/WEB-INF/lib/mysql-connector-java-5.0.8-bin.jar -Xss2048k -Xmx1g synchrony.core sql
root 24102 22429 0 18:36 pts/1 00:00:00 grep --color=auto confluence
[root@staging bin]# netstat -lntp |grep 8090
tcp6 0 0 :::8090 :::* LISTEN 22529/java