Bitbucket のゼロ ダウンタイム バックアップを使用する
Prerequisites
Block level file system snapshots
Your shared home directory must be on a file system volume capable of atomic (block level) snapshots, for example, Amazon EBS, LVM, NetApp, XFS, or ZFS. These technologies are becoming increasingly common in modern operating systems and storage solutions. If your shared home directory volume pre-dates these technologies, then you must first move your shared home directory onto one that supports block level snapshots before using zero downtime backup. You also need to script the steps to snapshot the volume in the backup process. The atlassian-bitbucket-diy-backup script does not include fully worked examples for every vendor technology. If you are unable to create such a snapshot, please consider another backup strategy.
Database snapshot technology
Your database must be capable of restoring a snapshot close to the same point in time as the home directory snapshot. The easiest way to do this is by taking database snapshots close to the home directory backup time. Alternatively, some databases support a vendor-specific "point-in-time recovery" feature at restore time. All database vendors supported by Bitbucket provide tools for taking fast snapshots and point-in-time recovery.
Bitbucket Server 4.8 or later
You must be running Bitbucket 4.8 or higher to use zero downtime backup. See the Bitbucket Server upgrade guide.
Configure the example DIY Backup script for zero downtime backup
With the above prerequisites, you can create backups with any method that performs home directory and database snapshots simultaneously. Atlassian provides an example atlassian-bitbucket-diy-backup script which can automate the process, and can be used as a starting point for you to configure and customize your own backup procedures.
Step 1: Get the script
Clone or pull the latest version of the sample atlassian-bitbucket-diy-backup script, for example:
git clone https://bitbucket.org/atlassianlabs/atlassian-bitbucket-diy-backup.git
cd atlassian-bitbucket-diy-backup
Step 2: Configure the script
Create the file bitbucket.diy-backup.vars.sh
by copying the appropriate bitbucket.diy-backup.vars.sh.example
, and edit it to match your environment. For example, to use Amazon EBS snapshots of the volume containing your shared home directory and Amazon RDS snapshots of your database, you might configure it as follows:
BACKUP_DATABASE_TYPE=amazon-rds
BACKUP_HOME_TYPE=amazon-ebs
BACKUP_ZERO_DOWNTIME=true
BITBUCKET_URL=https://your-bitbucket-url
If your shared home directory is not on Amazon EBS, then you must define a new BACKUP_HOME_TYPE
for your chosen file system technology. Give it a name (e.g., myhome
) that will identify the snapshot script to run in the next step.
BACKUP_HOME_TYPE=myhome
BACKUP_HOME_TYPE=rsync
is not a valid option to use with zero downtime backup.
Refer to Using Bitbucket Server DIY Backup and Using Bitbucket Server DIY Backup in AWS for more information on the configurable options in the DIY Backup example script.
Step 3: (If necessary) Script the snapshot process
If you have chosen BACKUP_HOME_TYPE
and BACKUP_DATABASE_TYPE
values that both already have worked examples included in the atlassian-bitbucket-diy-backup repository (e.g., ebs-home
and rds
), then you can just configure the appropriate variables in bitbucket.diy-backup.vars.sh
to match your environment, and skip this step.
If your shared home directory is not one of the worked examples provided in atlassian-bitbucket-diy-backup, then you must script the process of taking and restoring snapshots of your home directory volume.
Similarly if you wish to use the point-in-time recovery feature of your database with zero downtime backup (or some other functionality that does not have a fully worked example provided in atlassian-bitbucket-diy-backup), then you must script the process.
Back up your instance
Once your bitbucket.diy-backup.vars.sh
is correctly configured, SSH to the instance (or the appropriate node in a Data Center instance, typically the file server) and run the backup script from the atlassian-bitbucket-diy-backup
directory.
./bitbucket.diy-backup.sh
This script can also be run on a regular schedule (e.g., hourly), from cron
.
Restore from a backup
Step 1: Stop Bitbucket
The restore process only works while Bitbucket is stopped. Stop the Bitbucket services (on all nodes if your instance is a clustered Data Center instance).
sudo service atlbitbucket stop
sudo service atlbitbucket_search stop
See Starting and stopping Bitbucket Server for more information.
Step 2: Run the restore script
To restore, SSH to the instance (or the appropriate node in a Data Center instance, typically the file server) and run the restore script from the atlassian-bitbucket-diy-backup
directory.
./bitbucket.diy-restore.sh
Step 3: Start Bitbucket
Data Center customers at this point may enable integrity checking to scan for potential inconsistencies between the database and home directory, and resolve them if necessary so that your pull request and repository state are completely consistent with each other. See Running integrity checks in Bitbucket Data Center for further information.
Start the Bitbucket services (on all nodes if your instance is a clustered Data Center instance).
sudo service atlbitbucket start
sudo service atlbitbucket_search start
See Starting and stopping Bitbucket Server for more information.