Restore an Autonomous Database

This page describes how to restore an Autonomous Database from a backup.

You can restore an Autonomous Database from a backup to a specific point in time. When you restore a database, the database retains all the data and schema of the database up to the time of the backup, as well as the database options. To view backups for an existing Autonomous Database, see View backups for an Autonomous Database .

To learn more about how backup and recovery works on an Autonomous Database, see About Backup and Recovery on Autonomous Database .

Restore an Autonomous Database

To restore your Autonomous Database from a backup, follow these steps:

gcloud

Run the gcloud oracle-database autonomous-database restore command:

 gcloud oracle-database autonomous-database restore DATABASE_NAME 
--location= REGION_ID 
--project= PROJECT_NAME 
--restore-time= RESTORE_TIME 
 

Replace the following:

  • DATABASE_NAME : name of the database you want to restore.
  • REGION_ID : the region of your database.
  • PROJECT_NAME : the name of your Google Cloud project.
  • RESTORE_TIME : the backup time you want to restore your database to. You must use the endTime of the backup as the restore time.

To see a list of available backups for your database, see View backups for an Autonomous Database .

C#

  using 
  
  Google.Cloud.OracleDatabase.V1 
 
 ; 
 using 
  
  Google.LongRunning 
 
 ; 
 using 
  
  Google.Protobuf.WellKnownTypes 
 
 ; 
 using 
  
 System.Threading.Tasks 
 ; 
 public 
  
 sealed 
  
 partial 
  
 class 
  
 GeneratedOracleDatabaseClientSnippets 
 { 
  
 /// <summary>Snippet for RestoreAutonomousDatabaseAsync</summary> 
  
 /// <remarks> 
  
 /// 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/dotnet/docs/reference/help/client-configuration#endpoint. 
  
 /// </remarks> 
  
 public 
  
 async 
  
 Task 
  
 RestoreAutonomousDatabaseAsync 
 () 
  
 { 
  
 // Create client 
  
  OracleDatabaseClient 
 
  
 oracleDatabaseClient 
  
 = 
  
 await 
  
  OracleDatabaseClient 
 
 . 
  CreateAsync 
 
 (); 
  
 // Initialize request argument(s) 
  
 string 
  
 name 
  
 = 
  
 "projects/[PROJECT]/locations/[LOCATION]/autonomousDatabases/[AUTONOMOUS_DATABASE]" 
 ; 
  
  Timestamp 
 
  
 restoreTime 
  
 = 
  
 new 
  
  Timestamp 
 
 (); 
  
 // Make the request 
  
 Operation<AutonomousDatabase 
 , 
  
 OperationMetadata 
>  
 response 
  
 = 
  
 await 
  
 oracleDatabaseClient 
 . 
  RestoreAutonomousDatabaseAsync 
 
 ( 
 name 
 , 
  
 restoreTime 
 ); 
  
 // Poll until the returned long-running operation is complete 
  
 Operation<AutonomousDatabase 
 , 
  
 OperationMetadata 
>  
 completedResponse 
  
 = 
  
 await 
  
 response 
 . 
 PollUntilCompletedAsync 
 (); 
  
 // Retrieve the operation result 
  
  AutonomousDatabase 
 
  
 result 
  
 = 
  
 completedResponse 
 . 
 Result 
 ; 
  
 // Or get the name of the operation 
  
 string 
  
 operationName 
  
 = 
  
 response 
 . 
 Name 
 ; 
  
 // This name can be stored, then the long-running operation retrieved later by name 
  
 Operation<AutonomousDatabase 
 , 
  
 OperationMetadata 
>  
 retrievedResponse 
  
 = 
  
 await 
  
 oracleDatabaseClient 
 . 
  PollOnceRestoreAutonomousDatabaseAsync 
 
 ( 
 operationName 
 ); 
  
 // Check if the retrieved long-running operation has completed 
  
 if 
  
 ( 
 retrievedResponse 
 . 
 IsCompleted 
 ) 
  
 { 
  
 // If it has completed, then access the result 
  
  AutonomousDatabase 
 
  
 retrievedResult 
  
 = 
  
 retrievedResponse 
 . 
 Result 
 ; 
  
 } 
  
 } 
 } 
 

Go

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 oracledatabase 
  
 "cloud.google.com/go/oracledatabase/apiv1" 
  
 oracledatabasepb 
  
 "cloud.google.com/go/oracledatabase/apiv1/oracledatabasepb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // 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://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 oracledatabase 
 . 
 NewClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& oracledatabasepb 
 . 
 RestoreAutonomousDatabaseRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/oracledatabase/apiv1/oracledatabasepb#RestoreAutonomousDatabaseRequest. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 RestoreAutonomousDatabase 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

Java

  import 
  
 com.google.api.core. ApiFuture 
 
 ; 
 import 
  
 com.google.cloud.oracledatabase.v1. AutonomousDatabaseName 
 
 ; 
 import 
  
 com.google.cloud.oracledatabase.v1. OracleDatabaseClient 
 
 ; 
 import 
  
 com.google.cloud.oracledatabase.v1. RestoreAutonomousDatabaseRequest 
 
 ; 
 import 
  
 com.google.longrunning. Operation 
 
 ; 
 import 
  
 com.google.protobuf. Timestamp 
 
 ; 
 public 
  
 class 
 AsyncRestoreAutonomousDatabase 
  
 { 
  
 public 
  
 static 
  
 void 
  
 main 
 ( 
 String 
 [] 
  
 args 
 ) 
  
 throws 
  
 Exception 
  
 { 
  
 asyncRestoreAutonomousDatabase 
 (); 
  
 } 
  
 public 
  
 static 
  
 void 
  
 asyncRestoreAutonomousDatabase 
 () 
  
 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 
  
 ( 
  OracleDatabaseClient 
 
  
 oracleDatabaseClient 
  
 = 
  
  OracleDatabaseClient 
 
 . 
 create 
 ()) 
  
 { 
  
  RestoreAutonomousDatabaseRequest 
 
  
 request 
  
 = 
  
  RestoreAutonomousDatabaseRequest 
 
 . 
 newBuilder 
 () 
  
 . 
 setName 
 ( 
  
  AutonomousDatabaseName 
 
 . 
 of 
 ( 
 "[PROJECT]" 
 , 
  
 "[LOCATION]" 
 , 
  
 "[AUTONOMOUS_DATABASE]" 
 ) 
  
 . 
 toString 
 ()) 
  
 . 
  setRestoreTime 
 
 ( 
  Timestamp 
 
 . 
 newBuilder 
 (). 
 build 
 ()) 
  
 . 
 build 
 (); 
  
 ApiFuture<Operation> 
  
 future 
  
 = 
  
 oracleDatabaseClient 
 . 
  restoreAutonomousDatabaseCallable 
 
 (). 
 futureCall 
 ( 
 request 
 ); 
  
 // Do something. 
  
  Operation 
 
  
 response 
  
 = 
  
 future 
 . 
 get 
 (); 
  
 } 
  
 } 
 } 
 

Node.js

  /** 
 * 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. 
 * TODO(developer): Uncomment these variables before running the sample. 
 */ 
 /** 
 *  Required. The name of the Autonomous Database in the following format: 
 *  projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. 
 */ 
 // const name = 'abc123' 
 /** 
 *  Required. The time and date to restore the database to. 
 */ 
 // const restoreTime = {} 
 // Imports the Oracledatabase library 
 const 
  
 { 
 OracleDatabaseClient 
 } 
  
 = 
  
 require 
 ( 
 ' @google-cloud/oracledatabase 
' 
 ). 
 v1 
 ; 
 // Instantiates a client 
 const 
  
 oracledatabaseClient 
  
 = 
  
 new 
  
  OracleDatabaseClient 
 
 (); 
 async 
  
 function 
  
 callRestoreAutonomousDatabase 
 () 
  
 { 
  
 // Construct request 
  
 const 
  
 request 
  
 = 
  
 { 
  
 name 
 , 
  
 restoreTime 
 , 
  
 }; 
  
 // Run request 
  
 const 
  
 [ 
 operation 
 ] 
  
 = 
  
 await 
  
 oracledatabaseClient 
 . 
 restoreAutonomousDatabase 
 ( 
 request 
 ); 
  
 const 
  
 [ 
 response 
 ] 
  
 = 
  
 await 
  
 operation 
 . 
 promise 
 (); 
  
 console 
 . 
 log 
 ( 
 response 
 ); 
 } 
 callRestoreAutonomousDatabase 
 (); 
 

PHP

  use Google\ApiCore\ApiException; 
 use Google\ApiCore\OperationResponse; 
 use Google\Cloud\OracleDatabase\V1\AutonomousDatabase; 
 use Google\Cloud\OracleDatabase\V1\Client\OracleDatabaseClient; 
 use Google\Cloud\OracleDatabase\V1\RestoreAutonomousDatabaseRequest; 
 use Google\Protobuf\Timestamp; 
 use Google\Rpc\Status; 
 /** 
 * Restores a single Autonomous Database. 
 * 
 * @param string $formattedName The name of the Autonomous Database in the following format: 
 *                              projects/{project}/locations/{location}/autonomousDatabases/{autonomous_database}. Please see 
 *                              {@see OracleDatabaseClient::autonomousDatabaseName()} for help formatting this field. 
 */ 
 function restore_autonomous_database_sample(string $formattedName): void 
 { 
 // Create a client. 
 $oracleDatabaseClient = new OracleDatabaseClient(); 
 // Prepare the request message. 
 $restoreTime = new Timestamp(); 
 $request = (new RestoreAutonomousDatabaseRequest()) 
 ->setName($formattedName) 
 ->setRestoreTime($restoreTime); 
 // Call the API and handle any network failures. 
 try { 
 /** @var OperationResponse $response */ 
 $response = $oracleDatabaseClient->restoreAutonomousDatabase($request); 
 $response->pollUntilComplete(); 
 if ($response->operationSucceeded()) { 
 /** @var AutonomousDatabase $result */ 
 $result = $response->getResult(); 
 printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); 
 } else { 
 /** @var Status $error */ 
 $error = $response->getError(); 
 printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); 
 } 
 } catch (ApiException $ex) { 
 printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); 
 } 
 } 
 /** 
 * Helper to execute the sample. 
 * 
 * This sample 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, 
 *    please see the apiEndpoint client configuration option for more details. 
 */ 
 function callSample(): void 
 { 
 $formattedName = OracleDatabaseClient::autonomousDatabaseName( 
 '[PROJECT]', 
 '[LOCATION]', 
 '[AUTONOMOUS_DATABASE]' 
 ); 
 restore_autonomous_database_sample($formattedName); 
 } 
 

Python

  # 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://googleapis.dev/python/google-api-core/latest/client_options.html 
 from 
  
 google.cloud 
  
 import 
  oracledatabase_v1 
 
 def 
  
 sample_restore_autonomous_database 
 (): 
 # Create a client 
 client 
 = 
  oracledatabase_v1 
 
 . 
  OracleDatabaseClient 
 
 () 
 # Initialize request argument(s) 
 request 
 = 
  oracledatabase_v1 
 
 . 
  RestoreAutonomousDatabaseRequest 
 
 ( 
 name 
 = 
 "name_value" 
 , 
 ) 
 # Make the request 
 operation 
 = 
 client 
 . 
  restore_autonomous_database 
 
 ( 
 request 
 = 
 request 
 ) 
 print 
 ( 
 "Waiting for operation to complete..." 
 ) 
 response 
 = 
 operation 
 . 
 result 
 () 
 # Handle the response 
 print 
 ( 
 response 
 ) 
 

Ruby

  require 
  
 "google/cloud/oracle_database/v1" 
 ## 
 # Snippet for the restore_autonomous_database call in the OracleDatabase service 
 # 
 # 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/ruby/docs/reference. 
 # 
 # This is an auto-generated example demonstrating basic usage of 
 # Google::Cloud::OracleDatabase::V1::OracleDatabase::Client#restore_autonomous_database. 
 # 
 def 
  
 restore_autonomous_database 
  
 # Create a client object. The client can be reused for multiple calls. 
  
 client 
  
 = 
  
 Google 
 :: 
 Cloud 
 :: 
 OracleDatabase 
 :: 
 V1 
 :: 
 OracleDatabase 
 :: 
 Client 
 . 
 new 
  
 # Create a request. To set request fields, pass in keyword arguments. 
  
 request 
  
 = 
  
 Google 
 :: 
 Cloud 
 :: 
 OracleDatabase 
 :: 
 V1 
 :: 
 RestoreAutonomousDatabaseRequest 
 . 
 new 
  
 # Call the restore_autonomous_database method. 
  
 result 
  
 = 
  
 client 
 . 
 restore_autonomous_database 
  
 request 
  
 # The returned object is of type Gapic::Operation. You can use it to 
  
 # check the status of an operation, cancel it, or wait for results. 
  
 # Here is how to wait for a response. 
  
 result 
 . 
 wait_until_done! 
  
 timeout 
 : 
  
 60 
  
 if 
  
 result 
 . 
 response? 
  
 p 
  
 result 
 . 
 response 
  
 else 
  
 puts 
  
 "No response received." 
  
 end 
 end 
 
Create a Mobile Website
View Site in Mobile | Classic
Share by: