bitbucket server 备份/恢复
环境
- bitbucket server 4.14
- 外部mysql5.6
- 官方备份恢复工具bitbucket-backup-client-3.3.3
- mysql JDBC驱动 5.1.44 MySQL Connector/J
恢复工具准备
1、bitbucket-backup-client-3.3.3和MySQL Connector/J解压
2、修改bitbucket-backup-client-3.3.3的配置文件backup-config.properties,指定bitbucket的数据目录
bitbucket.home=/var/atlassian/application-data/bitbucket
3、MySQL JDBC驱动文件夹内的mysql-connector-java-5.1.44-bin.jar文件复制到bitbucket-backup-client-3.3.3文件夹内
4、拷贝bitbucket-backup-client-3.3.3文件夹到bitbucket server服务器上
备份
1、创建备份目录
mkdir /backup
2、修改配置文件backup-config.properties如下配置,请对应修改相关参数为你自己的正确值
##################################
# Backup properties
##################################
# Defines the username of the Bitbucket user with administrative privileges you wish to perform the backup.
# If omitted here it will be taken from the Java system property of the same name if supplied to the Backup Client on
# the command line. As a required value, backup will fail if it is not supplied through one of these mechanisms.
bitbucket.user=BITBUCKET_USER
# Defines the password of the Bitbucket user with administrative privileges you wish to perform the backup.
# If omitted here it will be taken from the Java system property of the same name if supplied on the command line
# to the Backup Client. As a required value, backup will fail if it is not supplied through one of these mechanisms.
bitbucket.password=BITBUCKER_PASSWORD
# Defines base URL of the Bitbucket instance you wish to back up. E.g. http://localhost:7990/bitbucket or
# http://bitbucketserver/. If omitted here it will be taken from the Java system property of the same name if supplied
# on the command line to the Backup Client. As a required value, backup will fail if it is not supplied through one of
# these mechanisms.
bitbucket.baseUrl=http://localhost:7990
# Defines where the Backup Client will store its own files, such as backup archives.
# If not specified, these files are stored beneath the working directory for the Backup Client.
# Backup files will be stored in a 'backup' subdirectory and logs will be stored in a 'logs' subdirectory.
# Note that on Windows, you must use two backslashes between paths. e.g. C:\\path\\to\\folder or instead
# use the forward slash e.g. C:/path/to/folder
backup.home=/backup
3、执行备份,无错误的话会在/backup/backup
下生成备份文件包,例如:bitbucket-20170914-020347-834.tar
java -jar /backup/bitbucket-backup-client-3.3.3/bitbucket-backup-client.jar
恢复
1、mysql创建和备份文件内的配置一样的数据库用户名、密码、库
2、修改配置文件backup-config.properties
如下配置,请对应修改相关参数为你自己的正确值
##################################
# Restore properties
##################################
# Optional. Enables overriding JDBC settings during the restore so that the restore can target a different database to
# the one that was backed up. Even if the other JDBC properties are defined, if this property is not set to true the
# JDBC settings will be ignored. If this is set to true then ALL of the following JDBC properties must be supplied.
jdbc.override=true
# Optional. Ignored if jdbc.override is not set to true. Overrides the JDBC driver to use during restore.
jdbc.driver=com.mysql.jdbc.Driver
# Optional. Ignored if jdbc.override is not set to true. Overrides the JDBC URL to use during restore.
jdbc.url=jdbc:mysql://DBHOST:PORT/DABASE_NAME?autoReconnect=true&characterEncoding=utf8&useUnicode=true&sessionVariables=storage_engine=InnoDB&useSSL=false
# Optional. Ignored if jdbc.override is not set to true. Overrides the JDBC user to use during restore.
jdbc.user=DB_USER
# Optional. Ignored if jdbc.override is not set to true. Overrides the JDBC password to use during restore.
jdbc.password=DB_PASSWORD
3、停止bitbucket服务,这里我选择直接kill掉进程
4、清空bitbucket数据目录
rm -rf /var/atlassian/application-data/bitbucket # 可能需要多次执行才会移除全部文件
5、执行恢复
java -jar /backup/bitbucket-backup-client-3.3.3/bitbucket-restore-client.jar /backup/bitbucket-20170914-020347-834.tar
6、启动服务,由于我使用的docker环境,所以只需要重启容器就可以了。其他环境请使用以下命令启动
/opt/atlassian/bitbucket/bin/start-bitbucket.sh