*************** *** 116,121 **** int inplace = 0; int delay_updates = 0; long block_size = 0; /* "long" because popt can't set an int32. */ /** Network address family. **/ --- 116,122 ---- int inplace = 0; int delay_updates = 0; long block_size = 0; /* "long" because popt can't set an int32. */ + time_t stop_at_utime = 0; /** Network address family. **/ *************** *** 377,382 **** rprintf(F," --password-file=FILE read password from FILE\n"); rprintf(F," --list-only list the files instead of copying them\n"); rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n"); rprintf(F," --write-batch=FILE write a batched update to FILE\n"); rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n"); rprintf(F," --read-batch=FILE read a batched update from FILE\n"); --- 378,385 ---- rprintf(F," --password-file=FILE read password from FILE\n"); rprintf(F," --list-only list the files instead of copying them\n"); rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n"); + rprintf(F," --stop-at=y-m-dTh:m Stop rsync at year-month-dayThour:minute\n"); + rprintf(F," --time-limit=MINS Stop rsync after MINS minutes have elapsed\n"); rprintf(F," --write-batch=FILE write a batched update to FILE\n"); rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n"); rprintf(F," --read-batch=FILE read a batched update from FILE\n"); *************** *** 398,404 **** OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP, OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD, OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE, - OPT_NO_D, OPT_SERVER, OPT_REFUSED_BASE = 9000}; static struct poptOption long_options[] = { --- 401,407 ---- OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP, OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD, OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE, + OPT_NO_D, OPT_STOP_AT, OPT_TIME_LIMIT, OPT_SERVER, OPT_REFUSED_BASE = 9000}; static struct poptOption long_options[] = { *************** *** 516,521 **** {"log-format", 0, POPT_ARG_STRING, &stdout_format, 0, 0, 0 }, /* DEPRECATED */ {"itemize-changes", 'i', POPT_ARG_NONE, 0, 'i', 0, 0 }, {"bwlimit", 0, POPT_ARG_INT, &bwlimit, 0, 0, 0 }, {"backup", 'b', POPT_ARG_NONE, &make_backups, 0, 0, 0 }, {"backup-dir", 0, POPT_ARG_STRING, &backup_dir, 0, 0, 0 }, {"suffix", 0, POPT_ARG_STRING, &backup_suffix, 0, 0, 0 }, --- 519,526 ---- {"log-format", 0, POPT_ARG_STRING, &stdout_format, 0, 0, 0 }, /* DEPRECATED */ {"itemize-changes", 'i', POPT_ARG_NONE, 0, 'i', 0, 0 }, {"bwlimit", 0, POPT_ARG_INT, &bwlimit, 0, 0, 0 }, + {"stop-at", 0, POPT_ARG_STRING, 0, OPT_STOP_AT, 0, 0 }, + {"time-limit", 0, POPT_ARG_STRING, 0, OPT_TIME_LIMIT, 0, 0 }, {"backup", 'b', POPT_ARG_NONE, &make_backups, 0, 0, 0 }, {"backup-dir", 0, POPT_ARG_STRING, &backup_dir, 0, 0, 0 }, {"suffix", 0, POPT_ARG_STRING, &backup_suffix, 0, 0, 0 }, *************** *** 1089,1094 **** usage(FINFO); exit_cleanup(0); default: /* A large opt value means that set_refuse_options() * turned this option off. */ --- 1094,1129 ---- usage(FINFO); exit_cleanup(0); + case OPT_STOP_AT: + arg = poptGetOptArg(pc); + if ((stop_at_utime = parse_time(arg)) == (time_t)-1) { + snprintf(err_buf, sizeof err_buf, + "invalid --stop-at format: %s\n", + arg); + rprintf(FERROR, "ERROR: %s", err_buf); + return 0; + } + if (stop_at_utime < time(NULL)) { + snprintf(err_buf, sizeof err_buf, + "--stop-at time is in the past: %s\n", + arg); + rprintf(FERROR, "ERROR: %s", err_buf); + return 0; + } + break; + + case OPT_TIME_LIMIT: + arg = poptGetOptArg(pc); + if ((stop_at_utime = atol(arg) * 60) <= 0) { + snprintf(err_buf, sizeof err_buf, + "invalid --time-limit value: %s\n", + arg); + rprintf(FERROR, "ERROR: %s", err_buf); + return 0; + } + stop_at_utime += time(NULL); + break; + default: /* A large opt value means that set_refuse_options() * turned this option off. */ *************** *** 1642,1647 **** args[ac++] = arg; } if (backup_dir) { args[ac++] = "--backup-dir"; args[ac++] = backup_dir; --- 1677,1691 ---- args[ac++] = arg; } + if (stop_at_utime) { + long mins = (stop_at_utime - time(NULL)) / 60; + if (mins <= 0) + mins = 1; + if (asprintf(&arg, "--time-limit=%ld", mins) < 0) + goto oom; + args[ac++] = arg; + } + if (backup_dir) { args[ac++] = "--backup-dir"; args[ac++] = backup_dir;