Snapshot
Last Updated:2020-07-20
Create a Snapshot
It supports the creation of system disk snapshot and CDS disk snapshot by using the following codes:
public static void createSnapshot(BccClient bccClient, String volumeId, String snapshotName, String desc) {
CreateSnapshotRequest createSnapshotRequest = new CreateSnapshotRequest();
// Specify a disk id
createSnapshotRequest.setVolumeId(volumeId);
// Specify snapshot name
createSnapshotRequest.setSnapshotName(snapshotName);
// Set snapshot description informations
createSnapshotRequest.setDesc(desc);
// Print return informations
System.out.println(bccClient.createSnapshot(createSnapshotRequest));
}
Query the Snapshot List
You can query the snapshot list by using the following codes:
public static void listSnapshot(BccClient bccClient) {
ListSnapshotsRequest listSnapshotsRequest = new ListSnapshotsRequest();
// Set a paging mark
listSnapshotsRequest.setMarker(snapshotId);
// Set the pagination return data size
listSnapshotsRequest.setMaxKeys(100);
// filter to create snapshots from specified disks
listSnapshotsRequest.setVolumeId(volumeId);
System.out.println(bccClient.listSnapshots(listSnapshotsRequest));
}
Query the Snapshot Details
You can query the snapshot details by using the following codes:
public static void getSnapshot(BccClient bccClient) {
System.out.println(bccClient.getSnapshot(snapshotId));
}
Delete a Snapshot
You can delete a snapshot by using the following codes:
public static void deleteSnap(BccClient bccClient) {
bccClient.deleteSnapshot(snapshotId);
}