This snippet creates a new backup and assigns it a specific ID. The code synchronously waits for the long-running backup creation operation to complete before returning a response.

## Code sample

### Java


To authenticate to AlloyDB, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).

    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();
        }
      }
    }

## What's next


To search and filter code samples for other Google Cloud products, see the
[Google Cloud sample browser](https://docs.cloud.google.com/docs/samples?product=alloydbforpostgresql).