/* Returns -1 on error, 0 on missing dir, and 1 on present dir. */
-static int validate_backup_dir(void)
-+static int validate_backup_dir(const char *buf)
++static int validate_backup_dir(char *buf)
{
STRUCT_STAT st;
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -152,10 +152,14 @@ int no_detach
+@@ -153,10 +153,14 @@ int no_detach
int write_batch = 0;
int read_batch = 0;
int backup_dir_len = 0;
char *tmpdir = NULL;
char *partial_dir = NULL;
char *basis_dir[MAX_BASIS_DIRS+1];
-@@ -167,7 +171,9 @@ char *stdout_format = NULL;
+@@ -168,7 +172,9 @@ char *stdout_format = NULL;
char *password_file = NULL;
char *rsync_path = RSYNC_PATH;
char *backup_dir = NULL;
char *sockopts = NULL;
char *usermap = NULL;
char *groupmap = NULL;
-@@ -678,6 +684,8 @@ void usage(enum logcode F)
+@@ -682,6 +688,8 @@ void usage(enum logcode F)
rprintf(F," --backup-deleted make backups only of deleted files\n");
rprintf(F," --backup-dir=DIR make backups into hierarchy based in DIR\n");
rprintf(F," --suffix=SUFFIX set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX);
rprintf(F," -u, --update skip files that are newer on the receiver\n");
rprintf(F," --inplace update destination files in-place (SEE MAN PAGE)\n");
rprintf(F," --append append data onto shorter files\n");
-@@ -988,7 +996,9 @@ static struct poptOption long_options[] = {
+@@ -998,7 +1006,9 @@ static struct poptOption long_options[] = {
{"backup-deleted", 0, POPT_ARG_VAL, &make_backups, 1, 0, 0 },
{"no-backup", 0, POPT_ARG_VAL, &make_backups, 0, 0, 0 },
{"backup-dir", 0, POPT_ARG_STRING, &backup_dir, 0, 0, 0 },
{"list-only", 0, POPT_ARG_VAL, &list_only, 2, 0, 0 },
{"read-batch", 0, POPT_ARG_STRING, &batch_name, OPT_READ_BATCH, 0, 0 },
{"write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_WRITE_BATCH, 0, 0 },
-@@ -2025,6 +2035,8 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -2091,6 +2101,8 @@ int parse_arguments(int *argc_p, const char ***argv_p)
tmpdir = sanitize_path(NULL, tmpdir, NULL, 0, SP_DEFAULT);
if (backup_dir)
backup_dir = sanitize_path(NULL, backup_dir, NULL, 0, SP_DEFAULT);
}
if (daemon_filter_list.head && !am_sender) {
filter_rule_list *elp = &daemon_filter_list;
-@@ -2046,6 +2058,14 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -2112,6 +2124,14 @@ int parse_arguments(int *argc_p, const char ***argv_p)
if (check_filter(elp, FLOG, dir, 1) < 0)
goto options_rejected;
}
}
if (!backup_suffix)
-@@ -2057,6 +2077,20 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -2123,6 +2143,20 @@ int parse_arguments(int *argc_p, const char ***argv_p)
backup_suffix);
return 0;
}
if (backup_dir) {
size_t len;
while (*backup_dir == '.' && backup_dir[1] == '/')
-@@ -2092,6 +2126,34 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -2158,6 +2192,34 @@ int parse_arguments(int *argc_p, const char ***argv_p)
"P *%s", backup_suffix);
parse_filter_str(&filter_list, backup_dir_buf, rule_template(0), 0);
}
+ } else if (make_backups && delete_mode && !delete_excluded && !am_server) {
+ snprintf(backup_dir_dels_buf, sizeof backup_dir_dels_buf,
+ "P *%s", backup_suffix_dels);
-+ parse_rule(&filter_list, backup_dir_dels_buf, 0, 0);
++ parse_filter_str(&filter_list, backup_dir_dels_buf, rule_template(0), 0);
+ }
if (preserve_times) {
preserve_times = PRESERVE_FILE_TIMES;
-@@ -2513,6 +2575,10 @@ void server_options(char **args, int *argc_p)
+@@ -2591,6 +2653,10 @@ void server_options(char **args, int *argc_p)
args[ac++] = "--backup-dir";
args[ac++] = backup_dir;
}
/* Only send --suffix if it specifies a non-default value. */
if (strcmp(backup_suffix, backup_dir ? "" : BACKUP_SUFFIX) != 0) {
-@@ -2521,7 +2587,14 @@ void server_options(char **args, int *argc_p)
+@@ -2599,7 +2665,14 @@ void server_options(char **args, int *argc_p)
goto oom;
args[ac++] = arg;
}