summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2013-09-21 01:51:42 +0200
committerGravatar Martin Szulecki2013-09-21 01:51:42 +0200
commit1d9f34fb5fa49c31ee30bdc4c98dc9a43bc5afb2 (patch)
treede4a2cf96f85a1f79f67afc33ce6703011ef50b1 /tools
parent0eaa1c53598054ec586108f2dec8b391dc0ac473 (diff)
downloadlibimobiledevice-1d9f34fb5fa49c31ee30bdc4c98dc9a43bc5afb2.tar.gz
libimobiledevice-1d9f34fb5fa49c31ee30bdc4c98dc9a43bc5afb2.tar.bz2
idevicebackup2: Add experimental support for using backups in the cloud
Diffstat (limited to 'tools')
-rw-r--r--tools/idevicebackup2.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index 47de171..b62a77b 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -88,7 +88,8 @@ enum cmd_flags {
CMD_FLAG_ENCRYPTION_ENABLE = (1 << 6),
CMD_FLAG_ENCRYPTION_DISABLE = (1 << 7),
CMD_FLAG_ENCRYPTION_CHANGEPW = (1 << 8),
- CMD_FLAG_FORCE_FULL_BACKUP = (1 << 9)
+ CMD_FLAG_FORCE_FULL_BACKUP = (1 << 9),
+ CMD_FLAG_ENABLE_CLOUD_BACKUP = (1 << 10)
};
static int backup_domain_changed = 0;
@@ -1280,6 +1281,7 @@ static void print_usage(int argc, char **argv)
printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n");
printf(" -s, --source UDID\tuse backup data from device specified by UDID\n");
printf(" -i, --interactive\trequest passwords interactively\n");
+ printf(" -c, --cloud\t\tUse cloud storage using iCloud account of device\n");
printf(" -h, --help\t\tprints usage information\n");
printf("\n");
}
@@ -1377,6 +1379,9 @@ int main(int argc, char *argv[])
backup_password = strdup(argv[i]);
continue;
}
+ else if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--cloud")) {
+ cmd_flags |= CMD_FLAG_ENABLE_CLOUD_BACKUP;
+ }
else if (!strcmp(argv[i], "--full")) {
cmd_flags |= CMD_FLAG_FORCE_FULL_BACKUP;
}
@@ -1400,9 +1405,9 @@ int main(int argc, char *argv[])
return -1;
}
if (!strcmp(argv[i], "on")) {
- cmd_flags |= CMD_FLAG_ENCRYPTION_ENABLE;
+ cmd_flags |= CMD_FLAG_ENCRYPTION_ENABLE;
} else if (!strcmp(argv[i], "off")) {
- cmd_flags |= CMD_FLAG_ENCRYPTION_DISABLE;
+ cmd_flags |= CMD_FLAG_ENCRYPTION_DISABLE;
} else {
printf("Invalid argument '%s' for encryption command; must be either 'on' or 'off'.\n", argv[i]);
}
@@ -1648,6 +1653,20 @@ int main(int argc, char *argv[])
}
}
+ opts = plist_new_dict();
+ if (cmd_flags & CMD_FLAG_ENABLE_CLOUD_BACKUP) {
+ PRINT_VERBOSE(1, "Enabling cloud backup for device...\n");
+ } else {
+ PRINT_VERBOSE(1, "Disabling cloud backup for device...\n");
+ }
+ plist_dict_insert_item(opts, "CloudBackupState", plist_new_bool(cmd & CMD_FLAG_ENABLE_CLOUD_BACKUP ? 1: 0));
+ err = mobilebackup2_send_request(mobilebackup2, "EnableCloudBackup", udid, source_udid, opts);
+ plist_free(opts);
+ if (err != MOBILEBACKUP2_E_SUCCESS) {
+ printf("Error setting cloud backup state on device, error code %d\n", err);
+ cmd = CMD_LEAVE;
+ }
+
uint64_t lockfile = 0;
if (cmd == CMD_BACKUP) {
do_post_notification(device, NP_SYNC_WILL_START);