バックアップの作成

このスニペットは、新しいバックアップを作成して特定の ID を割り当てます。このコードは、レスポンスを返す前に、長時間実行されるバックアップ作成オペレーションが完了するまで同期的に待機します。

コードサンプル

Java

AlloyDB に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、 ローカル開発環境の認証の設定をご覧ください。

import com.google.cloud.alloydb.v1beta.AlloyDBAdminClient;
import com.google.cloud.alloydb.v1beta.Backup;
import com.google.cloud.alloydb.v1beta.LocationName;

public class SyncCreateBackupStringBackupString {

  public static void main(String[] args) throws Exception {
    syncCreateBackupStringBackupString();
  }

  public static void syncCreateBackupStringBackupString() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (AlloyDBAdminClient alloyDBAdminClient = AlloyDBAdminClient.create()) {
      String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
      Backup backup = Backup.newBuilder().build();
      String backupId = "backupId2121930365";
      Backup response = alloyDBAdminClient.createBackupAsync(parent, backup, backupId).get();
    }
  }
}

次のステップ

他の Google Cloud プロダクトのコードサンプルを検索およびフィルタするには、Google Cloud サンプル ブラウザをご覧ください。