Perl script to create a backup of the YouTrack Cloud database, store it in a Backblaze B2 bucket, and optionally delete old backup files.
YT_TOKEN
- YouTrack permanent access tokenB2_APPLICATION_KEY_ID
- Backblaze application key IDB2_APPLICATION_KEY
- Backblaze application key secret
--baseurl
- YouTrack Cloud URL.--bucket
- Backblaze bucket name.--delay
- [optional] Seconds to wait between checks for database backup completion. (Default: 30)--keep
- [optional] Number of backup files to keep. (Default: 0, keep all backup files)--quiet
- [optional] Don't print information progress messages.--help
- [optional] Print usage message and exit.
- Obtain a YouTrack Cloud permanent access token.
- Log into YouTrack Cloud.
- Navigate to the
Account Security
tab in yourProfile
. - Click
New token...
in theTokens
section. - Provide a name for the token and ensure the
Scope
containsYouTrack
andYouTrack Administration
. - Set and export the environment variable
YT_TOKEN
with the YouTrack Cloud access token as its value (e.g., use a command likeexport YT_TOKEN=
youtrack-cloud-access-token). Note that preceding theexport
command with a space may prevent the command from being stored in the shell history. Refer to the description of theHISTCONTROL
shell variable in thebash
man page for details.
- Install b2.
- Create a Backblaze B2 bucket.
- Log into Backblaze.
- In the left navigation area, click
Buckets
. - Click
Create a Bucket
.- Bucket Unique Name: supply a name
- Files in Bucket are:
Private
- Default Encryption:
Enable
- Object Lock:
Disable
- Click
Create a Bucket
.
- Obtain a Backblaze Application Key. This manual process will restrict access to the B2 bucket you just created. The application key will have these capabilities: deleteFiles, listBuckets, listFiles, readBucketEncryption, readBucketReplications, readBuckets, readFiles, shareFiles, writeBucketEncryption, writeBucketReplications, writeFiles.
- Log into Backblaze.
- In the left navigation area, click
Application Keys
. - Click
Add a New Application Key
.- Name of Key: supply a name
- Allow access to Bucket(s): select the bucket you just created
- Type of Access:
Read and Write
- Allow List All Bucket Names: not selected
- File name prefix: leave blank
- Duration: leave blank
- Click
Create New Key
. - Save the
keyID
,keyName
, andapplicationKey
in a secure location.
- Set and export the environment variable
B2_APPLICATION_KEY_ID
with the Backblaze access token ID as its value. - Set and export the environment variable
B2_APPLICATION_KEY
with the Backblaze access token secret as its value. - To perform a YouTrack Cloud database backup: youtrack-backup.pl --baseurl yt-url --bucket b2-bucket-name
YT_URL
- URL to your instance of YouTrack Cloud.B2_BUCKET
- Name of the Backblaze B2 bucket.KEEP_COUNT
- Number of backups to keep.
The image created by the Dockerfile will run youtrack-backup.pl
with --delay
defaulted to 30
, --keep
defaulted to 0
, and --quiet
disabled.
- Copy
local.env.dist
tolocal.env
. - Set the values for the variables contained in
local.env
. - Build the Docker image:
docker build --tag youtrack-backup:latest .
- Run the Docker image:
docker run --env-file=local.env youtrack-backup:latest
This image is built automatically on Docker Hub as silintl/youtrack-backup