Skip to content

Snapshot Backup Examples

Authentication

  1. Go to the SkySQL API Key management page and generate an API key
  2. Export the value from the token field to an environment variable $API_KEY
    export API_KEY='... key data ...'
    
  3. Use it on subsequent request, e.g:
    curl --request GET 'https://api.skysql.com/skybackup/v1/backups/schedules' --header "X-API-Key: ${API_KEY}"
    

Snapshot Backup Scheduling

One-time Snapshot Example

    curl --location 'https://api.skysql.com/skybackup/v1/backups/schedules' \
    --header 'Content-Type: application/json' \
    --header 'X-API-Key: $API_KEY' \
    --data '{
        "backup_type": "snapshot",
        "schedule": "once",
        "service_id": "$SERVICE_ID"
    }'
  • API_KEY : SKYSQL API KEY, see SkySQL API Keys
  • SERVICE_ID : SkySQL serivce identifier, format dbtxxxxxx. You can fetch the service ID from the Fully qualified domain name(FQDN) of your service. E.g: in dbpgf17106534.sysp0000.db2.skysql.com, 'dbpgf17106534' is the service ID.You will find the FQDN in the Connect window

Cron Snapshot Example

    curl --location 'https://api.skysql.com/skybackup/v1/backups/schedules' \
    --header 'Content-Type: application/json' \
    --header 'X-API-Key: $API_KEY' \
    --data '{
        "backup_type": "snapshot",
        "schedule": "0 3 * * *",
        "service_id": "$SERVICE_ID"
    }'
  • API_KEY : SKYSQL API KEY, see SkySQL API Keys
  • SCHEDULE : Cron schedule, see Cron
  • SERVICE_ID : SkySQL serivce identifier, format dbxxxxxx
Backup status can be fetch using 'https://api.skysql.com/skybackup/v1/backups'. See the 'Backup Status' section for an example.