0

I want to take Oracle Cloud Database Backup using Oracle Java Cloud SDK. Help me doing this!

2 Answers2

1

Here's some example code to do this:

private static Backup createBackup(String databaseId) throws Exception {
    DatabaseWaiters waiters = CLIENT.getWaiters();

    String displayName = "db-backup";

    CreateBackupRequest createBackupRequest =
            CreateBackupRequest.builder()
                    .createBackupDetails(
                            CreateBackupDetails.builder()
                                    .databaseId(databaseId)
                                    .displayName(displayName)
                            .build())
                    .build();

    CreateBackupResponse createBackupResponse = CLIENT.createBackup(createBackupRequest);

    Backup backup = createBackupResponse.getBackup();

    waiters.forBackup(
                    GetBackupRequest.builder().backupId(backup.getId()).build(),
                    Backup.LifecycleState.Active,
                    new MaxTimeTerminationStrategy(60 * 60 * 1000),
                    new ExponentialBackoffDelayStrategy(60 * 1000))
            .execute();

    return backup;
}
Joe
  • 2,500
  • 1
  • 14
  • 12
  • I didn't understand the WAITER. Is this the same as com.oracle.bmc.waiter.Waiter? I changed WAITER to Waiter and also added import statements but after that my compiler is saying that " The method forBackup(......) is undefined for the type Waiter. Help me! – Tirumala Feb 06 '18 at 09:31
  • Updated the example to be more clear where the waiter is coming from – Joe Feb 06 '18 at 18:18
1

What Joe said. CLIENT in his example is a DatabaseClient:

https://docs.us-phoenix-1.oraclecloud.com/tools/java/latest/com/oracle/bmc/database/DatabaseClient.html