summaryrefslogtreecommitdiffstats
path: root/tools/idevicebackup2.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2012-12-08 21:45:19 +0100
committerGravatar Martin Szulecki2012-12-08 21:45:19 +0100
commit18e24e587d2cce6214a9da111d7d720c196a169a (patch)
tree421b76bfd346b525bb9260f91f2e0b2414f0a815 /tools/idevicebackup2.c
parentbe07014998dd7099157a59ae8a34ccddfb32ea35 (diff)
downloadlibimobiledevice-18e24e587d2cce6214a9da111d7d720c196a169a.tar.gz
libimobiledevice-18e24e587d2cce6214a9da111d7d720c196a169a.tar.bz2
idevicebackup2: Implement support to supply backup password for restore
Diffstat (limited to 'tools/idevicebackup2.c')
-rw-r--r--tools/idevicebackup2.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index 856c41c..ad3f0f6 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -1116,11 +1116,12 @@ static void print_usage(int argc, char **argv)
1116 printf("commands:\n"); 1116 printf("commands:\n");
1117 printf(" backup\tcreate backup for the device\n"); 1117 printf(" backup\tcreate backup for the device\n");
1118 printf(" restore\trestore last backup to the device\n"); 1118 printf(" restore\trestore last backup to the device\n");
1119 printf(" --system\trestore system files, too.\n"); 1119 printf(" --system\t\trestore system files, too.\n");
1120 printf(" --reboot\treboot the system when done.\n"); 1120 printf(" --reboot\t\treboot the system when done.\n");
1121 printf(" --copy\tcreate a copy of backup folder before restoring.\n"); 1121 printf(" --copy\t\tcreate a copy of backup folder before restoring.\n");
1122 printf(" --settings\trestore device settings from the backup.\n"); 1122 printf(" --settings\t\trestore device settings from the backup.\n");
1123 printf(" --remove\tremove items which are not being restored\n"); 1123 printf(" --remove\t\tremove items which are not being restored\n");
1124 printf(" --password PWD\tsupply the password of the source backup\n");
1124 printf(" info\t\tshow details about last completed backup of device\n"); 1125 printf(" info\t\tshow details about last completed backup of device\n");
1125 printf(" list\t\tlist files of last completed backup in CSV format\n"); 1126 printf(" list\t\tlist files of last completed backup in CSV format\n");
1126 printf(" unback\tunpack a completed backup in DIRECTORY/_unback_/\n\n"); 1127 printf(" unback\tunpack a completed backup in DIRECTORY/_unback_/\n\n");
@@ -1142,7 +1143,8 @@ int main(int argc, char *argv[])
1142 int cmd = -1; 1143 int cmd = -1;
1143 int cmd_flags = 0; 1144 int cmd_flags = 0;
1144 int is_full_backup = 0; 1145 int is_full_backup = 0;
1145 char *backup_directory = NULL; 1146 char* backup_directory = NULL;
1147 char* backup_password = NULL;
1146 struct stat st; 1148 struct stat st;
1147 plist_t node_tmp = NULL; 1149 plist_t node_tmp = NULL;
1148 plist_t info_plist = NULL; 1150 plist_t info_plist = NULL;
@@ -1206,6 +1208,17 @@ int main(int argc, char *argv[])
1206 else if (!strcmp(argv[i], "--remove")) { 1208 else if (!strcmp(argv[i], "--remove")) {
1207 cmd_flags |= CMD_FLAG_RESTORE_REMOVE_ITEMS; 1209 cmd_flags |= CMD_FLAG_RESTORE_REMOVE_ITEMS;
1208 } 1210 }
1211 else if (!strcmp(argv[i], "--password")) {
1212 i++;
1213 if (!argv[i]) {
1214 print_usage(argc, argv);
1215 return 0;
1216 }
1217 if (backup_password)
1218 free(backup_password);
1219 backup_password = strdup(argv[i]);
1220 continue;
1221 }
1209 else if (!strcmp(argv[i], "info")) { 1222 else if (!strcmp(argv[i], "info")) {
1210 cmd = CMD_INFO; 1223 cmd = CMD_INFO;
1211 verbose = 0; 1224 verbose = 0;
@@ -1471,7 +1484,11 @@ checkpoint:
1471 PRINT_VERBOSE(1, "Preserve settings of device: %s\n", ((cmd_flags & CMD_FLAG_RESTORE_SETTINGS) == 0 ? "Yes":"No")); 1484 PRINT_VERBOSE(1, "Preserve settings of device: %s\n", ((cmd_flags & CMD_FLAG_RESTORE_SETTINGS) == 0 ? "Yes":"No"));
1472 if (cmd_flags & CMD_FLAG_RESTORE_REMOVE_ITEMS) 1485 if (cmd_flags & CMD_FLAG_RESTORE_REMOVE_ITEMS)
1473 plist_dict_insert_item(opts, "RemoveItemsNotRestored", plist_new_bool(1)); 1486 plist_dict_insert_item(opts, "RemoveItemsNotRestored", plist_new_bool(1));
1474 PRINT_VERBOSE(1, "Remove items that are not restored: %s\n", ((cmd_flags & CMD_FLAG_RESTORE_REMOVE_ITEMS) ? "Yes":"No")); 1487 PRINT_VERBOSE(1, "Remove items that are not restored: %s\n", ((cmd_flags & CMD_FLAG_RESTORE_REMOVE_ITEMS) ? "Yes":"No"));
1488 if (backup_password != NULL) {
1489 plist_dict_insert_item(opts, "Password", plist_new_string(backup_password));
1490 }
1491 PRINT_VERBOSE(1, "Backup password: %s\n", (backup_password == NULL ? "No":"Yes"));
1475 1492
1476 err = mobilebackup2_send_request(mobilebackup2, "Restore", udid, source_udid, opts); 1493 err = mobilebackup2_send_request(mobilebackup2, "Restore", udid, source_udid, opts);
1477 plist_free(opts); 1494 plist_free(opts);