Commit 759ac870 authored by David Dykstra's avatar David Dykstra

Submit enhancement from Michael Zimmerman to allow --suffix to be used

with --backup-dir.
parent a1e0e45e
rsync changes since last release
ENHANCEMENTS:
* The --delete-after option now implies --delete. (Wayne Davison)
* The --suffix option can now be used with --backup-dir. (Michael
Zimmerman)
BUG FIXES:
* Fix "forward name lookup failed" errors on AIX 4.3.3. (John
......@@ -15,8 +22,6 @@ rsync changes since last release
http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=62489
* The --delete-after option now implies --delete.
INTERNAL:
* Many code cleanups and improved internal documentation. (Martin
......
......@@ -21,6 +21,7 @@
#include "rsync.h"
extern int verbose;
extern int suffix_specified;
extern char *backup_suffix;
extern char *backup_dir;
......@@ -203,12 +204,17 @@ static int keep_backup(char *fname)
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
......
......@@ -102,6 +102,7 @@ int no_detach = 0;
int write_batch = 0;
int read_batch = 0;
int suffix_specified = 0;
char *backup_suffix = BACKUP_SUFFIX;
char *tmpdir = NULL;
......@@ -296,7 +297,7 @@ enum {OPT_VERSION = 1000, OPT_SUFFIX, OPT_SENDER, OPT_SERVER, OPT_EXCLUDE,
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
{"version", 0, POPT_ARG_NONE, 0, OPT_VERSION, 0, 0},
{"suffix", 0, POPT_ARG_STRING, &backup_suffix, 0, 0, 0 },
{"suffix", 0, POPT_ARG_STRING, &backup_suffix, OPT_SUFFIX, 0, 0 },
{"rsync-path", 0, POPT_ARG_STRING, &rsync_path, 0, 0, 0 },
{"password-file", 0, POPT_ARG_STRING, &password_file, 0, 0, 0 },
{"ignore-times", 'I', POPT_ARG_NONE, &ignore_times , 0, 0, 0 },
......@@ -470,6 +471,13 @@ int parse_arguments(int *argc, const char ***argv, int frommain)
print_rsync_version(FINFO);
exit_cleanup(0);
case OPT_SUFFIX:
/* The value has already been set by popt, but
* we need to remember that a suffix was specified
* in case a backup-directory is used. */
suffix_specified = 1;
break;
case OPT_MODIFY_WINDOW:
/* The value has already been set by popt, but
* we need to remember that we're using a
......
......@@ -226,7 +226,7 @@ verb(
-R, --relative use relative path names
-b, --backup make backups (default ~ suffix)
--backup-dir make backups into this directory
--suffix=SUFFIX override backup suffix
--suffix=SUFFIX define backup suffix
-u, --update update only (don't overwrite newer files)
-l, --links copy symlinks as symlinks
-L, --copy-links copy the referent of symlinks
......@@ -374,10 +374,15 @@ control the backup suffix using the --suffix option.
dit(bf(--backup-dir=DIR)) In combination with the --backup option, this
tells rsync to store all backups in the specified directory. This is
very useful for incremental backups.
very useful for incremental backups. You can additionally
specify a backup suffix using the --suffix option
(otherwise the files backed up in the specified directory
will keep their original filenames).
dit(bf(--suffix=SUFFIX)) This option allows you to override the default
backup suffix used with the -b option. The default is a ~.
If --backup-dir and --suffix are both specified,
the SUFFIX is appended to the filename even in the backup directory.
dit(bf(-u, --update)) This forces rsync to skip any files for which the
destination file already exists and has a date later than the source
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment