34
34
import java .util .concurrent .TimeUnit ;
35
35
36
36
public class CopyBackupSample {
37
- public static void main (String [] args ) {
38
- if (args .length != 4 ) {
39
- throw new IllegalArgumentException (
40
- "Invalid number of arguments. "
41
- + "Usage: CopyBackupSample "
42
- + "<project-id> <instance-id> <source-backup-id> <destination-backup-id>" );
43
- }
44
- String projectId = args [0 ];
45
- String instanceId = args [1 ];
46
- String sourceBackupId = args [2 ];
47
- String destinationBackupId = args [3 ];
48
-
49
- try (Spanner spanner =
50
- SpannerOptions .newBuilder ().setProjectId (projectId ).build ().getService ()) {
51
- DatabaseAdminClient databaseAdminClient = spanner .getDatabaseAdminClient ();
52
- copyBackup (databaseAdminClient , projectId , instanceId , sourceBackupId , destinationBackupId );
53
- }
54
- }
55
-
56
37
static void copyBackup () {
57
38
// TODO(developer): Replace these variables before running the sample.
58
39
String projectId = "my-project" ;
@@ -87,12 +68,12 @@ static void copyBackup(
87
68
88
69
// Initiate the request which returns an OperationFuture.
89
70
System .out .println ("Copying backup [" + destinationBackup .getId () + "]..." );
90
- OperationFuture <Backup , CopyBackupMetadata > op =
71
+ OperationFuture <Backup , CopyBackupMetadata > operation =
91
72
databaseAdminClient .copyBackup (
92
73
BackupId .of (projectId , instanceId , sourceBackupId ), destinationBackup );
93
74
try {
94
75
// Wait for the backup operation to complete.
95
- destinationBackup = op .get ();
76
+ destinationBackup = operation .get ();
96
77
System .out .println ("Copied backup [" + destinationBackup .getId () + "]" );
97
78
} catch (ExecutionException e ) {
98
79
throw (SpannerException ) e .getCause ();
@@ -114,7 +95,7 @@ static void copyBackup(
114
95
destinationBackup .getProto ().getVersionTime ().getSeconds (),
115
96
destinationBackup .getProto ().getVersionTime ().getNanos (),
116
97
OffsetDateTime .now ().getOffset ())));
117
- return null ;
98
+ return ;
118
99
}
119
100
}
120
101
// [END spanner_copy_backup]
0 commit comments