github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/vbs/v2/backups/doc.go (about) 1 /* 2 Package backups enables management and retrieval of Backups 3 VBS service. 4 5 Example to List Backups 6 7 listOpts := backups.ListOpts{} 8 allBackups, err := backups.List(vbsClient, listOpts) 9 if err != nil { 10 panic(err) 11 } 12 13 for _, backup := range allBackups { 14 fmt.Printf("%+v\n", backup) 15 } 16 17 Example to Get a Backup 18 19 getbackup,err:=backups.Get(vbsClient, "6149e448-dcac-4691-96d9-041e09ef617f").Extract() 20 if err != nil { 21 panic(err) 22 } 23 24 fmt.Println(getbackup) 25 26 Example to Create a Backup 27 28 createOpts := backups.CreateOpts{ 29 Name:"backup-test", 30 VolumeId:"5024a06e-6990-4f12-9dcc-8fe26b01a710", 31 } 32 33 jobInfo, err := backups.Create(vbsClient, createOpts).ExtractJobResponse() 34 if err != nil { 35 panic(err) 36 } 37 38 err1 := backups.WaitForJobSuccess(client, int(120), jobInfo.JobID) 39 if err1 != nil { 40 panic(err1) 41 } 42 43 Label := "backup_id" 44 entity, err2 := backups.GetJobEntity(client, jobInfo.JobID, Label) 45 fmt.Println(entity) 46 if err2 != nil { 47 panic(err2) 48 } 49 50 Example to Delete a Backup 51 52 backupID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c" 53 err := backups.Delete(vbsClient, backupID).ExtractErr() 54 if err != nil { 55 panic(err) 56 } 57 58 Example to Restore a Backup 59 60 restoreOpts := backups.BackupRestoreOpts{VolumeId:"5024a06e-6990-4f12-9dcc-8fe26b01a710"} 61 62 restore,err := backups.CreateBackupRestore(vbsClient,"87566ed6-72cb-4053-aa6e-6f6216b3d507",backup).ExtractBackupRestore() 63 if err != nil { 64 panic(err) 65 } 66 */ 67 package backups