bitbucket server 备份/恢复(docker)
环境
- bitbucket server 4.14 for docker
- 外部mysql5.7
- 恢复工具Bitbucket Server DIY Backup
- apt-get update && apt-get install mysql-client-5.5 jq rsync vim -y
恢复工具准备
1、创建目录
mkdir -p /backup/
mkdir -p /backup/bitbucket-backup # 备份临时生成目录
mkdir -p /backup/archives # 备份打包目录
2、克隆恢复仓库到备份目录
git clone git@bitbucket.org:atlassianlabs/atlassian-bitbucket-diy-backup.git
3、创建配置文件 bitbucket.diy-backup.vars.sh
#!/bin/bash
CURL_OPTIONS="-L -s -f"
INSTANCE_NAME=bitbucket
BITBUCKET_URL=http://localhost:7990
BITBUCKET_HOME=/var/atlassian/application-data/bitbucket/
# BITBUCKET_HOME=/backup/restore/ # for restore
BITBUCKET_UID=daemon
BITBUCKET_GID=daemon
BACKUP_HOME_TYPE=rsync
BACKUP_DATABASE_TYPE=mysql
BACKUP_ARCHIVE_TYPE=tar
BITBUCKET_BACKUP_USER=admin
BITBUCKET_BACKUP_PASS=admin
BITBUCKET_BACKUP_EXCLUDE_REPOS=()
# PostgreSQL options
POSTGRES_HOST=
POSTGRES_USERNAME=
POSTGRES_PASSWORD=
POSTGRES_PORT=5432
# MySQL options
BITBUCKET_DB=bitbucket
MYSQL_HOST=mysql
MYSQL_USERNAME=root
MYSQL_PASSWORD=123456
MYSQL_BACKUP_OPTIONS=
BITBUCKET_BACKUP_ROOT=/backup/bitbucket-backup
BITBUCKET_BACKUP_DB=${BITBUCKET_BACKUP_ROOT}/bitbucket-db
BITBUCKET_BACKUP_HOME=${BITBUCKET_BACKUP_ROOT}/bitbucket-home/
BITBUCKET_BACKUP_ARCHIVE_ROOT=/backup/archives
# Used by the scripts for verbose logging. If not true only errors will be shown.
BITBUCKET_VERBOSE_BACKUP=TRUE
HIPCHAT_URL=https://api.hipchat.com
HIPCHAT_ROOM=
HIPCHAT_TOKEN=
备份
切换到备份工具目录下运行
./bitbucket.diy-backup.sh
恢复
1、建立空数据库以及账号密码
2、修改恢复工具配置文件bitbucket.diy-backup.vars.sh
,将BITBUCKET_HOME配置修改为/backup/restore/
3、执行恢复(不带参数运行将显示BITBUCKET_BACKUP_ARCHIVE_ROOT
目录下可用的备份)
./bitbucket.diy-restore.sh bitbucket-20171005-083749
4、停止bitbucket-server容器,然后替换/backup/restore/
目录下的所有文件到/var/atlassian/application-data/bitbucket/
目录下启动容器,恢复完成