summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-06-29 11:20:09 -0700
committerDianne Hackborn <hackbod@google.com>2009-06-29 11:20:09 -0700
commit360efc12dcfece46e5999505bd8042cba56a4289 (patch)
treedb70e392621fb18e0fd4cadacce6b210677c2249
parent5570651ee3c96a2f9e484583291cad2b533c865a (diff)
downloadextras-360efc12dcfece46e5999505bd8042cba56a4289.tar.gz
Rename backup command to rawbu.
Rename the command to reflect that it is a low-level backup, since we are introducing a higher-level backup mechanism in the framework. Also change the syntax a little to make it less dangerous -- you now must explicitly specify a backup or restore, and if you don't do so it will abort with its help message.
-rw-r--r--backup/Android.mk2
-rw-r--r--backup/backup.cpp40
2 files changed, 34 insertions, 8 deletions
diff --git a/backup/Android.mk b/backup/Android.mk
index 6a3d3fee..b5803905 100644
--- a/backup/Android.mk
+++ b/backup/Android.mk
@@ -7,7 +7,7 @@ LOCAL_SRC_FILES:= backup.cpp
LOCAL_SHARED_LIBRARIES := libcutils libc
-LOCAL_MODULE:= backup
+LOCAL_MODULE:= rawbu
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_MODULE_TAGS := debug
diff --git a/backup/backup.cpp b/backup/backup.cpp
index 48f64eec..22c016d7 100644
--- a/backup/backup.cpp
+++ b/backup/backup.cpp
@@ -591,10 +591,21 @@ done:
static void show_help(const char *cmd)
{
- fprintf(stderr,"Usage: %s [options] [backup-file-path]\n", cmd);
+ fprintf(stderr,"Usage: %s COMMAND [options] [backup-file-path]\n", cmd);
+ fprintf(stderr, "commands are:\n"
+ " help Show this help text.\n"
+ " backup Perform a backup of /data.\n"
+ " restore Perform a restore of /data.\n");
fprintf(stderr, "options include:\n"
- " -r Perform restore of previous backup.\n");
+ " -h Show this help text.\n");
+ fprintf(stderr, "\nThe %s command allows you to perform low-level\n"
+ "backup and restore of the /data partition. This is\n"
+ "where all user data is kept, allowing for a fairly\n"
+ "complete restore of a device's state. Note that\n"
+ "because this is low-level, it will only work across\n"
+ "builds of the same (or very similar) device software.\n",
+ cmd);
}
} /* namespace android */
@@ -607,24 +618,39 @@ int main (int argc, char **argv)
fprintf(stderr, "error -- %s must run as root\n", argv[0]);
exit(-1);
}
-
- if (argc == 2 && 0 == strcmp(argv[1], "--help")) {
+
+ if (argc < 2) {
+ fprintf(stderr, "No command specified.\n");
+ android::show_help(argv[0]);
+ exit(-1);
+ }
+
+ if (0 == strcmp(argv[1], "restore")) {
+ restore = 1;
+ } else if (0 == strcmp(argv[1], "help")) {
android::show_help(argv[0]);
exit(0);
+ } else if (0 != strcmp(argv[1], "backup")) {
+ fprintf(stderr, "Unknown command: %s\n", argv[1]);
+ android::show_help(argv[0]);
+ exit(-1);
}
+ optind = 2;
+
for (;;) {
int ret;
- ret = getopt(argc, argv, "r");
+ ret = getopt(argc, argv, "h");
if (ret < 0) {
break;
}
switch(ret) {
- case 'r':
- restore = 1;
+ case 'h':
+ android::show_help(argv[0]);
+ exit(0);
break;
default: