Stash is now known as Bitbucket Server.
See the

Unknown macro: {spacejump}

of this page, or visit the Bitbucket Server documentation home page.

This page describes using the Stash Backup Client, which has been supported from Stash 2.8 and is the backup strategy that Atlassian recommends for most people.

For information about other backup strategies for Stash, see Data recovery and backups. That page also discusses the tight coupling between the Stash file system on disk and the database that Stash uses.

With any strategy, you should consider scheduling the backup window so as to minimise the impact on Stash availability. You might consider checking the access logs to determine patterns of lowest usage to help with this.

We highly recommend that you establish a data recovery plan that is aligned with your company's policies.

Questions? Check out FAQ - Data recovery and backup.

 

Download the Stash Backup Client from the Atlassian Marketplace, or from here:

Unzip the client into a directory on the Stash server.

動作の仕組み

The Backup Client implements a common and universal way to back up a Stash instance, and does the following:

  1. Locks access to the Stash application, the repositories managed by Stash and the Stash database for the entire duration of the back up. This state is called 'maintenance mode'.
  2. すべての Git およびデータベース操作が完了したことを確認します。
  3. Performs an application-specific backup of the Stash home directory and the Stash database. The backup is generic and does not depend on the server or database configuration. 
  4. バックアップ ファイルをローカル ファイルシステムの指定された場所に、1 つの tar ファイルして保管します。 
  5. Unlocks Stash from maintenance mode.

A user will get an error message if they try to access the Stash web interface, or use the Stash hosting services, when Stash is in maintenance mode.

The client supports Windows and Linux platforms, and Stash versions 2.7 and higher, but does not provide ways to integrate with your organizations IT policies or processes.

As an indication of the unavailability time that can be expected when using the Stash Backup Client, in our testing and internal use we have seen downtimes for Stash of 7–8 minutes with repositories totalling 6 GB in size. For comparison, using Stash DIY Backup for the same repositories typically results in a downtime of less than a minute.

バックアップ対象

Backup Client は次のすべてのデータをバックアップします。

  • the database Stash is connected to (either the internal or external DB)
  • 管理された Git リポジトリ
  • the Stash audit logs
  • インストール済みのプラグインとそれらのデータ

バックアップには次のファイルおよびディレクトリは含まれません。

  • export/*
  • log/* (監査ログを除く)
  • data/db* (DB 内の HSQL データはバックアップされますが、ディスクのファイルはバックアップされません)
  • tmp
  • plugins ディレクトリ (installed-plugins ディレクトリを除く) 

Note that the caches directory is included in the backup because it contains previously indexed heads. 

Backing up Stash using the client

The Backup Client must be run from somewhere with access to the Stash home directory. Usually, you will run the Backup Client directly on the Stash server.  Run the client with the following command:

java -jar <path/to/stash-backup-client.jar>

Configuration options are kept in the backup-config.properties file that is included with the client – this file is automatically read when the client is run. The required properties include:

あるいは、次のプロパティをコマンドラインで指定できます。これらは "-D" プレフィックスを持ち、"-jar" パラメーターの前に配置する必要があります。次に例を示します。

java -Dstash.password="pass" -Dstash.user="user" -Dstash.baseUrl="http://stash" -jar stash-backup-client.jar 

Cancelling the client backup

必要に応じて、実行中のクライアント バックアップ操作をキャンセルできます。

バックアップのキャンセル方法

  1. ターミナル (または Windows のコマンド プロンプト) でクライアントによって返されるキャンセル トークンをコピーします。

  2. Go to the Stash interface in your browser. Stash will display this screen:



  3. Click Cancel backup, and enter the cancel token:

  4. [バックアップを取消] をクリックします。

Restoring Stash into the backed-up DB instance

In order to ensure accidental restores do not delete existing data, the restore client will only restore into an empty home directory and an empty database. Therefore, if you intend to perform the restore into the current environment, make sure that these prerequisites are met.

Run the client with the following command:

java -Dstash.home="path/to/stash/home" -jar stash-restore-client.jar 

Restoring Stash into a newly created DB instance

When restoring Stash, the restore client must be run on the machine that Stash should be restored to. In order to ensure accidental restores do not delete existing data, the restore client will only restore into an empty home directory and an empty database.

The new database should be configured following the instructions in Connecting Stash to an external database and its sub-page that corresponds to your database type. 

If you are using MySQL

Download and install the JDBC driver

The JDBC drivers for MySQL are not bundled with the Backup Client (due to licensing restrictions). You need to download and install the driver yourself.

  1. Download the MySQL Connector/J JDBC driver from the download site.
  2. ダウンロードした zip/tar.gz ファイルを解凍します。
  3. Copy the mysql-connector-java-5.1.XX-bin.jar file from the extracted directory to your <path/to/backup/client> /jdbc directory.

The restore client also uses the  backup-config.properties  file, where the properties can include:

stash.home

The full path to a directory that the restore client will populate with the Stash home data. This directory must be empty.
On Windows, you must use two backslashes ( \\ ) or a single forward slash ( / ) to separate paths. 
jdbc.override

By default, the restore client will restore into the same database that was backed up. If jdbc.override is set to true, the restore client will restore into the database specified by the jdbc properties in the table below. The database must be empty.

jdbc.driver The driver class that Stash should use to login to the new database. See examples below.
jdbc.url新しいデータベースの接続の詳細です。JDBC URL の形式を持ちます。以降の例をご確認ください。
jdbc.userThe username that Stash should use to login to the new database.
jdbc.password
The username that Stash should use to login to the new database.

Sample JDBC properties

Sample jdbc.driver and jdbc.url properties are shown below:

データベースjdbc.driverjdbc.url
MySQLcom.mysql.jdbc.Driver

jdbc:mysql://HOSTNAME:PORT/DATABASE?autoReconnect=true&characterEncoding=utf8&useUnicode=true&sessionVariables=storage_engine%3DInnoDB

Oracleoracle.jdbc.driver.OracleDriverjdbc:oracle:thin:@//HOSTNAME:PORT/SERVICE
PostgreSQLorg.postgresql.Driverjdbc:postgresql://HOSTNAME:PORT/DATABASE
SQL Servercom.microsoft.sqlserver.jdbc.SQLServerDriverjdbc:sqlserver://HOSTNAME:PORT;databaseName=DATABASE;

Setting JDBC properties on the command line

You can also set JDBC properties on the command line with the following command:

java -Djdbc.override=true -Djdbc.driver=org.postgresql.Driver -Djdbc.url=jdbc:postgresql://HOSTNAME:PORT/DATABASE -Djdbc.user=dbuser -Djdbc.password=dbpasswd -Dstash.home="path/to/stash/home" -jar /path/to/stash-restore-client.jar /path/to/original/backup/file
  • ラベルなし