diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-06-29 11:20:09 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-06-29 11:20:09 -0700 |
commit | 360efc12dcfece46e5999505bd8042cba56a4289 (patch) | |
tree | db70e392621fb18e0fd4cadacce6b210677c2249 /backup/backup.cpp | |
parent | 5570651ee3c96a2f9e484583291cad2b533c865a (diff) | |
download | extras-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.
Diffstat (limited to 'backup/backup.cpp')
-rw-r--r-- | backup/backup.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
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: |