Bitbucket备份恢复

我们需要备份什么?

home directory:contains  repository data, log files, plugins, and so on.

database:contains data about pull requests, comments, users, groups, permissions, and so on.

备份的策略

 
Zero Downtime Backup
DIY Backup
Backup Client
Summary A technique that eliminates downtime completely using internally consistent database snapshots and block-level filesystem snapshots A technique that minimizes downtime using incremental copy or vendor-specific snapshot technology

Simple but unsuitable for use in high availability environments.

An external utility which locks a Bitbucket Server instance and backs up its entire home directory and database in a vendor-independent format.

Downtime (tick) Zero at backup time.

(warning) Low. Only needs to lock Bitbucket briefly to create a consistent snapshot. Downtime can be as low as a few seconds.

(error) High. Bitbucket is locked for the entire duration of the backup process, which may take several minutes or longer, especially in large organizations.

Minimum product version Bitbucket 4.8+

Stash 2.12+

Bitbucket 4.0+

Stash 2.7+

Bitbucket 4.0+

Bitbucket Server (tick) Supported. Bitbucket tolerates (but does not attempt to resolve) any inconsistencies between the home directory and database after restoring. (tick) Supported (tick) Supported
Bitbucket Data Center (tick) Supported. Bitbucket can perform an integrity check at restore time to scan for inconsistencies between the home directory and database,and resolve them. (tick) Supported (error) Not supported, even if you are running on one cluster node.
Minimum requirements
  • Requires you to use the snapshot tools of your file system and database vendor. Example scripts are provided.
  • Requires your home directory to be on a file system volume capable of atomic (block level) snapshots, for example, Amazon EBSLVMNetAppXFS, or ZFS.
  • Minimizing the time between database andfilesystem snapshots (or using vendor-specific point-in-time recovery) reduces the chances of inconsistencies occurring

Requires you to use the snapshot tools of your file system and database vendor. Example scripts are provided.

No special requirements. "Just works" out of the box.
Backup format Vendor-specific database snapshot and block level file system snapshot of the entire disk volume. Vendor-specific database dump and file system snapshot.

Database vendor-independent.

Documentation Using Bitbucket zero downtime backup Using Bitbucket Server DIY Backup Using the Bitbucket Server Backup Client

我们这边采用第三种方式进行备份。

备份包括:

  • the database Bitbucket Server is connected to (either the internal or external DB)
  • managed Git repositories
  • the Bitbucket Server audit logs
  • installed plugins and their data

不包括:

  • export/*
  • log/* (except for the audit logs)
  • shared/data/db* (HSQL data in the DB is backed up, but the files on disk are not)
  • tmp
  • the plugins directory (except for the installed-plugins directory)  

下载指定备份插件: release of the Bitbucket Server Backup Client that is compatible with your Bitbucket Server instance

解压下载的插件包,进行相关配置(编辑 backup-config.properties 文件)

#备份

bitbucket.home=/var/atlassian/application-data/Bitbucket  #bitbucket家目录

bitbucket.user=bitbucket # bitbucker备份的账户

bitbucket.password=xxxxx #账户密码

bitbucket.baseUrl=http://localhost:7990 #bitbucket地址

backup.home=/S3/bitbucket #  备份的路径

#恢复

jdbc.override=true

jdbc.driver=org.postgresql.Driver #配置引擎为postgresql

jdbc.url=jdbc:postgresql://localhost:5432/bitbucket    #postgresql 中Bitbucket 仓库数据库地址

jdbc.user=bitbucket # postgresql 中 Bitbucket 账户

jdbc.password=xxxxx  #密码

#备份命令

java -jar /path/to/bitbucket-backup-client.jar

#恢复命令  需先清空数据库和bitbucket家目录中的数据

停掉Bitbucket服务

rm -rf /var/atlassian/application-data/bitbucket

su - postgres ; psql ; drop database bitbucket;create database bitbucket

java -jar /path/to/bitbucket-restore-client.jar  /S3/bitbucket/backup/bitbucket-xxxxx.tar

chown -R atlbitbucket.atlbitbucket /var/atlassian/application-data/bitbucket

参考链接:https://confluence.atlassian.com/bitbucketserver0414/using-the-bitbucket-server-backup-client-895368009.html

赠人玫瑰,手有余香,如果我的文章有幸能够帮到你,麻烦帮忙点下右下角的推荐,谢谢!

作者: imcati

出处: https://www.cnblogs.com/imcati/>

本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出, 原文链接

原文地址:https://www.cnblogs.com/imcati/p/9634870.html