Skip to content

How to backup and restore via API

Last updated on

It is possible to back up and restore your configurations (such as alert configs, alert rules, scrape configs) and Grafana dashboards.

This document describes how to call the Observability API using the stackit curl wrapper. Of course, you can also use other suitable tools or programming languages to communicate with the Observability API.

For a complete list of all available endpoints, parameters, and schemas, refer to the STACKIT Observability Backup API Specification.

You can retrieve your current backup retention policies by providing your project ID and instance ID.

Command:

Terminal window
stackit curl -X GET "https://argus.api.eu01.stackit.cloud/v1/projects/$PROJECT_ID/instances/$INSTANCE_ID/backup-retentions" \
-H "Content-Type: application/json"

Response:

{
"grafanaBackupRetention": "14d",
"alertConfigBackupRetention": "14d",
"alertRulesBackupRetention": "14d",
"scrapeConfigBackupRetention": "14d",
"message": "Successfully got backup retention"
}

You can list all active backup schedules for a specific target. The input parameter backupTarget accepts any of the following values: alertConfig, alertRules, scrapeConfig, or grafana.

Command:

Terminal window
BACKUP_TARGET="alertConfig"
stackit curl -X GET "https://argus.api.eu01.stackit.cloud/v1/projects/$PROJECT_ID/instances/$INSTANCE_ID/backup-schedules?backupTarget=$BACKUP_TARGET" \
-H "Content-Type: application/json"

Response:

{
"alertConfigBackupSchedules": [
{
"schedule": "0 * * * *",
"scheduleId": "dc2ca261-de00-4de8-a25d-68607a56c28b"
}
],
"message": "Successfully got backup schedules"
}

To automate your backups, create a new schedule using cron syntax. The parameter backupTarget accepts alertConfig, alertRules, scrapeConfig, or grafana.

Command:

Terminal window
BACKUP_TARGET="alertConfig"
stackit curl -X POST "https://argus.api.eu01.stackit.cloud/v1/projects/$PROJECT_ID/instances/$INSTANCE_ID/backup-schedules?backupTarget=$BACKUP_TARGET" \
-H "Content-Type: application/json" \
--data '{"schedule": "0 * * * *"}'

Response:

{
"message": "Backup schedule will be created"
}

To see all available backups that can be restored, you can request a list of historical backup timestamps. The backupTarget accepts alertConfig, alertRules, scrapeConfig, or grafana.

Command:

Terminal window
BACKUP_TARGET="alertConfig"
stackit curl -X GET "https://argus.api.eu01.stackit.cloud/v1/projects/$PROJECT_ID/instances/$INSTANCE_ID/backups?backupTarget=$BACKUP_TARGET" \
-H "Content-Type: application/json"

Response:

{
"alertConfigBackups": ["01-12-2021T00:00:18", "01-12-2021T00:05:12", "30-11-2021T23:55:13"],
"message": "Successfully got backups"
}

If you are about to make significant changes, you can trigger an immediate manual backup. The backupTarget accepts alertConfig, alertRules, scrapeConfig, or grafana.

Command:

Terminal window
BACKUP_TARGET="alertConfig"
stackit curl -X POST "https://argus.api.eu01.stackit.cloud/v1/projects/$PROJECT_ID/instances/$INSTANCE_ID/backups?backupTarget=$BACKUP_TARGET" \
-H "Content-Type: application/json"

Response:

{
"message": "Backup will be created"
}

To restore an older state, provide the exact backup date in the URL. The restoreTarget accepts alertConfig, alertRules, scrapeConfig, or grafana.

Command:

Terminal window
BACKUP_DATE="30-11-2021T19:35:16"
RESTORE_TARGET="alertConfig"
stackit curl -X POST "https://argus.api.eu01.stackit.cloud/v1/projects/$PROJECT_ID/instances/$INSTANCE_ID/backup-restores/$BACKUP_DATE?restoreTarget=$RESTORE_TARGET" \
-H "Content-Type: application/json"

Response:

{
"message": "Restore will be proceeded"
}