Skip to content

Commit

Permalink
Added native backup to admin tool client
Browse files Browse the repository at this point in the history
  • Loading branch information
jroper committed Oct 14, 2011
1 parent b2d0f1d commit 57550f8
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/java/voldemort/VoldemortAdminTool.java
Expand Up @@ -191,6 +191,15 @@ public static void main(String[] args) throws Exception {
.withValuesSeparatedBy(',')
.ofType(Integer.class);
parser.accepts("repair-job", "Clean after rebalancing is done");
parser.accepts("native-backup",
"Perform a native backup")
.withRequiredArg()
.describedAs("store-name")
.ofType(String.class);
parser.accepts("backup-dir")
.withRequiredArg()
.describedAs("backup-directory")
.ofType(String.class);

OptionSet options = parser.parse(args);

Expand All @@ -206,7 +215,8 @@ public static void main(String[] args) throws Exception {
&& (options.has("add-stores") || options.has("delete-store")
|| options.has("ro-metadata") || options.has("set-metadata")
|| options.has("get-metadata") || options.has("check-metadata") || options.has("key-distribution"))
|| options.has("truncate") || options.has("clear-rebalancing-metadata") || options.has("async"))) {
|| options.has("truncate") || options.has("clear-rebalancing-metadata") || options.has("async")
|| options.has("native-backup"))) {
System.err.println("Missing required arguments: " + Joiner.on(", ").join(missing));
printHelp(System.err, parser);
System.exit(1);
Expand Down Expand Up @@ -268,11 +278,17 @@ public static void main(String[] args) throws Exception {
if(options.has("repair-job")) {
ops += "l";
}
if(options.has("native-backup")) {
if (!options.has("backup-dir")) {
Utils.croak("A backup directory must be specified with dir");
}
ops += "n";
}
if(ops.length() < 1) {
Utils.croak("At least one of (delete-partitions, restore, add-node, fetch-entries, "
+ "fetch-keys, add-stores, delete-store, update-entries, get-metadata, ro-metadata, "
+ "set-metadata, check-metadata, key-distribution, clear-rebalancing-metadata, async, repair-job) "
+ "must be specified");
+ "set-metadata, check-metadata, key-distribution, clear-rebalancing-metadata, async, "
+ "repair-job, native-backup) must be specified");
}

List<String> storeNames = null;
Expand Down Expand Up @@ -421,6 +437,11 @@ public static void main(String[] args) throws Exception {
if(ops.contains("l")) {
executeRepairJob(nodeId, adminClient);
}
if (ops.contains("n")) {
String backupDir = (String) options.valueOf("backup-dir");
String storeName = (String) options.valueOf("native-backup");
adminClient.nativeBackup(nodeId, storeName, backupDir);
}
} catch(Exception e) {
e.printStackTrace();
Utils.croak(e.getMessage());
Expand Down

0 comments on commit 57550f8

Please sign in to comment.