X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/8950ac03f8fd0fb645c7d2374195ea884d091f72..1c8162a921cbae803b3bf375fda4aa7916bcfc68:/backup.c diff --git a/backup.c b/backup.c index a30e7ff8..97ec957e 100644 --- a/backup.c +++ b/backup.c @@ -21,6 +21,7 @@ #include "rsync.h" extern int verbose; +extern int suffix_specified; extern char *backup_suffix; extern char *backup_dir; @@ -197,18 +198,23 @@ static int keep_backup(char *fname) if (do_stat (fname, &st)) return 1; #endif - file = make_file(-1, fname, NULL, 1); + file = make_file(fname, NULL, NO_EXCLUDES); /* the file could have disappeared */ if (!file) return 1; /* make a complete pathname for backup file */ - if (strlen(backup_dir) + strlen(fname) > (MAXPATHLEN - 1)) { + if (strlen(backup_dir) + strlen(fname) + + (suffix_specified ? strlen(backup_suffix) : 0) > (MAXPATHLEN - 1)) { rprintf (FERROR, "keep_backup filename too long\n"); return 0; } - snprintf(keep_name, sizeof (keep_name), "%s/%s", backup_dir, fname); + if (suffix_specified) { + snprintf(keep_name, sizeof (keep_name), "%s/%s%s", backup_dir, fname, backup_suffix); + } else { + snprintf(keep_name, sizeof (keep_name), "%s/%s", backup_dir, fname); + } #ifdef HAVE_MKNOD @@ -288,4 +294,3 @@ int make_backup(char *fname) else return (make_simple_backup(fname)); } -