Skip to content

Commit ad16096

Browse files
authored
Merge pull request #32 from c0llab0rat0r/document-api-usage
Document api usage
2 parents ce5f556 + 01ca9d4 commit ad16096

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
target/
2+
.bsp
23
.idea/
34
.idea_modules/
45
project/project/

README.MD

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ It originates from [pull request #845](takezoe/gitbucket#845) and can be used to
88

99
### H2 Backup
1010

11-
This plugin allows to backup the underlying H2 database used by default by GitBucket.
11+
This plugin allows you to backup the underlying H2 database used by default by GitBucket.
1212

1313
## Usage
1414

15-
The plugin provides 2 ways to backup the H2 database:
15+
The plugin provides two ways to backup the H2 database:
1616

1717
- via an administration page and a backup button
18-
- via an HTTP call to http://YOUR_GITBUCKET/database/backup
18+
- via an HTTP call to `http://YOUR_GITBUCKET/api/v3/plugins/database/backup
1919

2020
The default backup file points to `GITBUCKET_DATA/backup/gitbucket-db-YYYY-MM-DD-hhmm.zip` where:
2121

@@ -34,13 +34,27 @@ The default backup file points to `GITBUCKET_DATA/backup/gitbucket-db-YYYY-MM-DD
3434

3535
Using your preferred tool (curl, wget, ...) it is possible start a backup of the H2 database.
3636

37-
The URL to call looks like `http://YOUR_GITBUCKET/database/backup`.
37+
The URL to call looks like `http://YOUR_GITBUCKET/api/v3/plugins/database/backup`
3838

39-
You can pass an optional argument `dest` that references the destination file path where the backup will be done on the server. For example calling `http://YOUR_GITBUCKET/database/backup?dest=/var/backups/gitbucket.zip` will do an H2 backup of the gitbucket database into the file `/var/backups/gitbucket.zip`.
39+
You can pass an optional argument `dest` that references the destination file path where the backup will be done on the server.
40+
For example calling `http://YOUR_GITBUCKET/api/v3/plugins/database/backup?dest=/var/backups/gitbucket.zip` will do an H2 backup of the gitbucket database into the file `/var/backups/gitbucket.zip`.
4041
Since `1.3.0`, the _dest_ parameter can denote a relative file path, in this case the file will be created relatively to `GITBUCKET_DATA`.
4142

4243
On success, you will receive a `HTTP 200` answer with a body containing `done: FULL_PATH_OF_BACKUP_FILE`.
4344

45+
### HTTP API Authorization
46+
47+
The api uses token authentication. To generate a token:
48+
49+
1. Login to Gitbucket with an administrative account
50+
2. In the top-right corner, click the user menu
51+
3. Click `Account Settings`
52+
4. On the left, click `Applications`
53+
5. In `Generate new token` enter a description and click `Generate token`
54+
6. Add the token to your http call, such as with `curl`:
55+
56+
`curl -i -H 'Authorization: token your_token_value' http://YOUR_GITBUCKET/api/v3/plugins/database/backup`
57+
4458
## Compatibility
4559

4660
Plugin version | GitBucket version

0 commit comments

Comments
 (0)