mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Add 'zfs send --saved' flag
This commit adds the --saved (-S) to the 'zfs send' command. This flag allows a user to send a partially received dataset, which can be useful when migrating a backup server to new hardware. This flag is compatible with resumable receives, so even if the saved send is interrupted, it can be resumed. The flag does not require any user / kernel ABI changes or any new feature flags in the send stream format. Reviewed-by: Paul Dagnelie <pcd@delphix.com> Reviewed-by: Alek Pinchuk <apinchuk@datto.com> Reviewed-by: Paul Zuchowski <pzuchowski@datto.com> Reviewed-by: Christian Schwarz <me@cschwarz.com> Reviewed-by: Matt Ahrens <matt@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Closes #9007
This commit is contained in:
committed by
Brian Behlendorf
parent
9ab6109fb5
commit
ba0ba69e50
+35
-4
@@ -318,7 +318,8 @@ get_usage(zfs_help_t idx)
|
||||
"<filesystem|volume|snapshot>\n"
|
||||
"\tsend [-DnPpvLec] [-i bookmark|snapshot] "
|
||||
"--redact <bookmark> <snapshot>\n"
|
||||
"\tsend [-nvPe] -t <receive_resume_token>\n"));
|
||||
"\tsend [-nvPe] -t <receive_resume_token>\n"
|
||||
"\tsend [-Pnv] --saved filesystem\n"));
|
||||
case HELP_SET:
|
||||
return (gettext("\tset <property=value> ... "
|
||||
"<filesystem|volume|snapshot> ...\n"));
|
||||
@@ -4207,11 +4208,12 @@ zfs_do_send(int argc, char **argv)
|
||||
{"raw", no_argument, NULL, 'w'},
|
||||
{"backup", no_argument, NULL, 'b'},
|
||||
{"holds", no_argument, NULL, 'h'},
|
||||
{"saved", no_argument, NULL, 'S'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/* check options */
|
||||
while ((c = getopt_long(argc, argv, ":i:I:RDpvnPLeht:cwbd:",
|
||||
while ((c = getopt_long(argc, argv, ":i:I:RDpvnPLeht:cwbd:S",
|
||||
long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'i':
|
||||
@@ -4271,6 +4273,9 @@ zfs_do_send(int argc, char **argv)
|
||||
flags.embed_data = B_TRUE;
|
||||
flags.largeblock = B_TRUE;
|
||||
break;
|
||||
case 'S':
|
||||
flags.saved = B_TRUE;
|
||||
break;
|
||||
case ':':
|
||||
/*
|
||||
* If a parameter was not passed, optopt contains the
|
||||
@@ -4321,7 +4326,7 @@ zfs_do_send(int argc, char **argv)
|
||||
if (resume_token != NULL) {
|
||||
if (fromname != NULL || flags.replicate || flags.props ||
|
||||
flags.backup || flags.dedup || flags.holds ||
|
||||
redactbook != NULL) {
|
||||
flags.saved || redactbook != NULL) {
|
||||
(void) fprintf(stderr,
|
||||
gettext("invalid flags combined with -t\n"));
|
||||
usage(B_FALSE);
|
||||
@@ -4342,6 +4347,23 @@ zfs_do_send(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (flags.saved) {
|
||||
if (fromname != NULL || flags.replicate || flags.props ||
|
||||
flags.doall || flags.backup || flags.dedup ||
|
||||
flags.holds || flags.largeblock || flags.embed_data ||
|
||||
flags.compress || flags.raw || redactbook != NULL) {
|
||||
(void) fprintf(stderr, gettext("incompatible flags "
|
||||
"combined with saved send flag\n"));
|
||||
usage(B_FALSE);
|
||||
}
|
||||
if (strchr(argv[0], '@') != NULL) {
|
||||
(void) fprintf(stderr, gettext("saved send must "
|
||||
"specify the dataset with partially-received "
|
||||
"state\n"));
|
||||
usage(B_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (flags.raw && redactbook != NULL) {
|
||||
(void) fprintf(stderr,
|
||||
gettext("Error: raw sends may not be redacted.\n"));
|
||||
@@ -4355,7 +4377,16 @@ zfs_do_send(int argc, char **argv)
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (resume_token != NULL) {
|
||||
if (flags.saved) {
|
||||
zhp = zfs_open(g_zfs, argv[0], ZFS_TYPE_DATASET);
|
||||
if (zhp == NULL)
|
||||
return (1);
|
||||
|
||||
err = zfs_send_saved(zhp, &flags, STDOUT_FILENO,
|
||||
resume_token);
|
||||
zfs_close(zhp);
|
||||
return (err != 0);
|
||||
} else if (resume_token != NULL) {
|
||||
return (zfs_send_resume(g_zfs, &flags, STDOUT_FILENO,
|
||||
resume_token));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user