[Other doc versions]
[Doc downloads (PDF, HTML, XML)]
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:
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 は次のすべてのデータをバックアップします。
バックアップには次のファイルおよびディレクトリは含まれません。
export/*log/* (監査ログを除く)data/db* (DB 内の HSQL データはバックアップされますが、ディスクのファイルはバックアップされません)tmpplugins ディレクトリ (installed-plugins ディレクトリを除く)
Note that the caches directory is included in the backup because it contains previously indexed heads.
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 properties are fully documented in the backup-config.properties file, but include:
| Defines the location of the home directory of the Stash instance you wish to back up or restore to. REQUIRED If omitted here it will be taken from the |
| Defines the username of the Stash user with administrative privileges you wish to perform the backup. REQUIRED ここで省略した場合、同じ名前の Java システム プロパティから取得されます (コマンド ラインで Backup Client に指定していた場合)。これは必須の値であるため、これらのメカニズムのいずれかで指定されていない場合は、バックアップが失敗します。 |
| Defines the password of the Stash user with administrative privileges you wish to perform the backup. REQUIRED ここで省略した場合、同じ名前の Java システム プロパティから取得されます (コマンド ラインで Backup Client に指定していた場合)。これは必須の値であるため、これらのメカニズムのいずれかで指定されていない場合は、バックアップが失敗します。 |
stash.baseUrl | Defines base URL of the Stash instance you wish to back up. REQUIRED E.g. http://localhost:7990/stash or http://stashserver/. 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. |
| Backup Client がバックアップ アーカイブなどの自身のファイルを保存する場所を定義します。 指定しない場合、これらのファイルは Backup Client の作業ディレクトリの配下に保存されます。バックアップ ファイルは Windows の場合、パスの間に 2 つのバックスラッシュを使用する必要がある点にご注意ください。例: |
あるいは、次のプロパティをコマンドラインで指定できます。これらは "-D" プレフィックスを持ち、"-jar" パラメーターの前に配置する必要があります。次に例を示します。
java -Dstash.password="admin" -Dstash.user="admin" -Dstash.baseUrl="http://localhost:7990" -Dstash.home=path/to/stash/home -jar stash-backup-client.jar
必要に応じて、実行中のクライアント バックアップ操作をキャンセルできます。
バックアップのキャンセル方法
This section applies if you intend to perform a restore into the existing DB configuration/technology. Therefore, in this scenario it is assumed the restore is done to the same server as the one in which Stash was originally backed up.
The stash-restore-client.jar will use the JDBC connection configuration contained in your previous backup generated through the usage of the stash-backup-client.jar. That means you won't need to specify the parameters jdbc.driver, jdbc.url, jdbc.user and jdbc.password at the restore time - it will use whatever is configured in stash-config.properties contained in the STASH_HOME within the backup tarball.
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. So, make sure that these prerequisites are met:
java -Dstash.home="path/to/stash/home" -jar stash-restore-client.jar /path/to/original/backup/file
If you are using MySQL
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.
<path/to/backup/client>/jdbc directory.This section applies if you intend to perform a restore into a newly created DB. This scenario assumes the restore is done to a server different to the one in which Stash was originally backed up.
The restore process is database agnostic, meaning the database you are restoring your backup to could be of a different configuration/technology from the originally backed up database.
The stash-restore-client.jar will use the JDBC connection configuration specified in the parameters jdbc.driver, jdbc.url, jdbc.user and jdbc.password at the restore time. Once the database backup is successfully restored, it will write the specified parameters in the stash-config.properties within the newly restored STASH_HOME - which will, therefore, enable the new instance connect to the restored database once the steps outlined below are followed.
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. So, make sure that these prerequisites are met:
You can run the restore client from the command line. In this scenario, as you will have created a new database, you will need to specify the new JDBC parameters while running the command so the client will be able to restore your previous database successfully.
この例では、新しく作成された PostgreSQL への復元を行っています。
java -Djdbc.override=true -Djdbc.driver=org.postgresql.Driver -Djdbc.url=jdbc:postgresql://HOSTNAME:PORT/DATABASE -Djdbc.user=stashuser -Djdbc.password=password -Dstash.home="path/to/stash/home" -jar /path/to/stash-restore-client.jar /path/to/original/backup/file
あるいは、backup-config.properties ファイルでこれらのパラメータを構成することもできます。ファイルが現在のワーキング ディレクトリに存在することを確認してください。サンプル ファイルはクライアントに同梱されます。プロパティは、backup-config.properties ファイルに完全に文書化されており、詳細は以下で説明されています。
| 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.driver | The driver class that Stash should use to login to the new database. See examples below. |
jdbc.url | 新しいデータベースの接続の詳細です。JDBC URL の形式を持ちます。以降の例をご確認ください。 |
jdbc.user | The 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. |
jdbc.driver および jdbc.url プロパティの例を以下に示します。
| データベース | jdbc.driver | jdbc.url |
|---|---|---|
| MySQL | com.mysql.jdbc.Driver | |
| Oracle | oracle.jdbc.driver.OracleDriver | jdbc:oracle:thin:@//HOSTNAME:PORT/SERVICE |
| PostgreSQL | org.postgresql.Driver | jdbc:postgresql://HOSTNAME:PORT/DATABASE |
| SQL Server | com.microsoft.sqlserver.jdbc.SQLServerDriver | jdbc:sqlserver://HOSTNAME:PORT;databaseName=DATABASE; |