Skip to main content

YouTrack Database Backup

The YouTrack Database Backup recipe creates a new database backup for a YouTrack instance using the YouTrack REST API and verifies that the backup completed successfully. Combined with a schedule trigger, backups can be started and monitored regularly from TeamCity.

Recipe IDjjideenschmiede/youtrack-database-backup
MarketplaceYouTrack Database Backup
Source codeGitHub

How It Works​

  1. The recipe starts the backup via the YouTrack REST API
  2. It then checks the status of the backup every 10 seconds and logs the progress in the build log
  3. As soon as YouTrack reports the backup as finished, the build step ends successfully

The build step fails if the backup cannot be started, is cancelled, YouTrack reports an error, or the backup does not complete within 60 minutes.

The backup is created by YouTrack itself and stored in the location configured there. The recipe does not download a backup file.

Installation​

The recipe requires TeamCity 2025.03 or later. How to add it to a build configuration is described under Using a Recipe.

Inputs​

InputRequiredDescription
YouTrack Base URLYesBase URL of the YouTrack instance, for example https://youtrack.example.com
YouTrack Permanent TokenYesPermanent token for authentication with the YouTrack API

Regular Backups​

  1. Create a separate build configuration for the backup
  2. Add the recipe as the only build step
  3. Add a Schedule Trigger, for example daily at night
  4. Set up a notification for failed builds, so that a failed backup is noticed

Technical Details​

PropertyValue
Starting the backupPOST /api/admin/databaseBackup/settings
Status checkGET /api/admin/databaseBackup/settings/backupStatus, every 10 seconds
Maximum duration60 minutes
Timeout per request30 seconds for connecting, 60 seconds for the start, 30 seconds per status check

Error Messages​

MessageCause
Failed to trigger backup (HTTP 401) or (HTTP 403)The token is invalid or the user lacks the permission
Failed to trigger backup (HTTP 404)The base URL is not correct
Backup was cancelledThe backup was cancelled in YouTrack
Backup failed with errorYouTrack reports an error while creating the backup; the message from YouTrack is included
Backup did not complete within 60 minutesThe backup takes longer than 60 minutes

Notes​

  • The base URL is given without /api; a trailing slash is ignored.

  • The user the token belongs to needs the permission to manage database backups in YouTrack.

  • The input field for the token is a text field. Store the token as a parameter of the type Password and reference it in the input field, so that it is not kept in plain text in the configuration.

  • The TeamCity agent must be able to reach the YouTrack instance over the network.