How to Identify On-Demand Backups via gcloud?

93 views
Skip to first unread message

Skyler Slade

unread,
May 2, 2017, 12:47:42 PM5/2/17
to Google Cloud SQL discuss

Hi there,


I like to identify on-demand backups (vs. automatic backups) via gcloud. For example, I see these backups in the console:

Using gcloud, I can request a list of backups
    gcloud sql backups list --instance=my-instance-name --format=json

This gives a document like this for all backups:

  {
    "backupConfiguration": "99033b25-2e89-456a-b443-6ea0dcd7d43d",
    "dueTime": "2017-04-21T06:34:20.432000+00:00",
    "endTime": "2017-04-21T06:38:10.200000+00:00",
    "enqueuedTime": "2017-04-21T06:34:20.432000+00:00",
    "instance": "my-instance-name",
    "kind": "sql#backupRun",
    "startTime": "2017-04-21T06:34:20.432000+00:00",
    "status": "SUCCESSFUL"
  }

However, this object doesn't indicate if the backup was automatic or on-demand. Additionally, the gcloud command to describe a backup shows similar output and doesn't indicate if it was automatic or on-demand. For example,

$ gcloud sql backups describe "2017-04-28T05:00:00.538000+00:00" --instance=my-instance-name
backupConfiguration: 99033b25-2e89-456a-b443-6ea0dcd7d43d
dueTime: '2017-04-28T05:00:00.538000+00:00'
endTime: '2017-04-28T08:04:18.427000+00:00'
enqueuedTime: '2017-04-28T08:00:39.424000+00:00'
instance: my-instance-name
kind: sql#backupRun
startTime: '2017-04-28T08:00:39.429000+00:00'
status: SUCCESSFUL

Is it possible using gcloud to differentiate between automatic backups and on-demand backups? Potentially I could add a "this is on-demand" description to each on-demand backup that I perform, however, the description does not appear to be returned in the above output.

David Newgas

unread,
May 2, 2017, 1:06:32 PM5/2/17
to Google Cloud SQL discuss
If you use the v1beta4 api (which isn't currently used by gcloud) the type is returned. For exmaple:

$ curl -H "Authorization: Bearer $(gcloud auth print-access-token)" 'https://www.googleapis.com/sql/v1beta4/projects/PROJECT/instances/INSTANCE/backupRuns?maxResults=2'
{
 "kind": "sql#backupRunsList",
 "nextPageToken": "1493717296474",
 "items": [
  {
   "kind": "sql#backupRun",
   "id": "1493744506814",
   "instance": "INSTANCE",
   "description": "dd",
   "windowStartTime": "2017-05-02T17:01:46.814Z",
   "status": "SUCCESSFUL",
   "type": "ON_DEMAND",
   "enqueuedTime": "2017-05-02T17:01:46.814Z",
   "startTime": "2017-05-02T17:01:46.814Z",
   "endTime": "2017-05-02T17:02:09.623Z"
  },
  {
   "kind": "sql#backupRun",
   "id": "1493708400533",
   "instance": "INSTANCE",
   "windowStartTime": "2017-05-02T07:00:00.533Z",
   "status": "SUCCESSFUL",
   "type": "AUTOMATED",
   "enqueuedTime": "2017-05-02T09:28:16.474Z",
   "startTime": "2017-05-02T09:28:16.485Z",
   "endTime": "2017-05-02T09:28:43.225Z"
  }
 ]
}



--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/46d24c6e-0a94-4709-925e-f61f0e2498e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pia Chamberlain

unread,
May 3, 2017, 1:58:19 PM5/3/17
to Google Cloud SQL discuss
Logged b/37946645.
Reply all
Reply to author
Forward
0 new messages