Handling of backup files - two new features proposed

Dave Dykstra dwd at bell-labs.com
Fri Apr 26 07:04:02 EST 2002


Why go through the trouble to nullify the --suffix option when --backup-dir
is specified?  I think it would be better to allow them to come in either
order anyway.

- Dave Dykstra

On Fri, Apr 26, 2002 at 01:52:24AM +0200, Michael Zimmermann wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> At Thursday 25 April 2002 23:47 Dave Dykstra wrote:
> > > [about proposing two new options]
> > >      --backup-owner=USER
> > >      --backup-group=GROUP
> >
> > I don't like that; I think it is too special purpose.  Can't you follow
> > up the rsync with a find/chown?
> 
> Yes, I agree. I was too fixed to the idea of preserving the user's
> quotas all the time.
> 
> 
> > > [about Adding a non-default suffix to backup-files in the backup-directory]
> >
> > That sounds like a fine idea to me.
> 
> If you want to include it, I've added a patch against the current version -
> just as I would do the changes.
> 
> 
> Greetings
> Michael
> - -- 
> Michael Zimmermann (Vegaa Safety and Security for Internet Services)
> <zim at vegaa.de>   phone +49 89 6283 7632    hotline +49 163 823 1195
> Key fingerprint = 1E47 7B99 A9D3 698D 7E35  9BB5 EF6B EEDB 696D 5811
> 
> 
> 
> - --------------------------- snip -------------------------------
> diff -u rsync/backup.c rsync.dev/backup.c
> - --- rsync/backup.c      Fri Apr 26 00:51:18 2002
> +++ rsync.dev/backup.c  Fri Apr 26 01:03:39 2002
> @@ -203,12 +203,12 @@
>         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) + strlen(backup_suffix) > (MAXPATHLEN - 1)) {
>                  rprintf (FERROR, "keep_backup filename too long\n");
>                  return 0;
>          }
> 
> - -        snprintf(keep_name, sizeof (keep_name), "%s/%s", backup_dir, fname);
> +        snprintf(keep_name, sizeof (keep_name), "%s/%s%s", backup_dir, fname, backup_suffix);
> 
> 
>  #ifdef HAVE_MKNOD
> diff -u rsync/options.c rsync.dev/options.c
> - --- rsync/options.c     Fri Apr 26 00:52:15 2002
> +++ rsync.dev/options.c Fri Apr 26 01:37:09 2002
> @@ -361,7 +361,7 @@
>    {"log-format",       0,  POPT_ARG_STRING, &log_format , 0, 0, 0 },
>    {"bwlimit",          0,  POPT_ARG_INT,    &bwlimit , 0, 0, 0 },
>    {"address",          0,  POPT_ARG_STRING, &bind_address, 0, 0, 0 },
> - -  {"backup-dir",       0,  POPT_ARG_STRING, &backup_dir , 0, 0, 0 },
> +  {"backup-dir",       0,  POPT_ARG_STRING, &backup_dir , OPT_BACKUP_DIR, 0, 0 },
>    {"hard-links",      'H', POPT_ARG_NONE,   &preserve_hard_links , 0, 0, 0 },
>    {"read-batch",       0,  POPT_ARG_STRING, &batch_prefix, OPT_READ_BATCH, 0, 0 },
>    {"write-batch",      0,  POPT_ARG_STRING, &batch_prefix, OPT_WRITE_BATCH, 0, 0 },
> @@ -470,6 +470,13 @@
>                          print_rsync_version(FINFO);
>                         exit_cleanup(0);
> 
> +               case OPT_BACKUP_DIR:
> +                       /* Using backup-directory nullifies
> +                          a default backup-suffix */
> +                       if (strcmp(backup_suffix,BACKUP_SUFFIX) == 0)
> +                               backup_suffix = "";
> +                       break;
> +
>                 case OPT_MODIFY_WINDOW:
>                          /* The value has already been set by popt, but
>                           * we need to remember that we're using a
> diff -u rsync/rsync.1 rsync.dev/rsync.1
> - --- rsync/rsync.1       Fri Apr 26 00:52:44 2002
> +++ rsync.dev/rsync.1   Fri Apr 26 01:45:56 2002
> @@ -428,11 +428,18 @@
>  .IP "\fB--backup-dir=DIR\fP"
>  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)\&. If the default suffix should
> +be used in this case, the --suffix=~ parameter must be given explicitly
> +after the --backup-dir parameter on the command line\&.
>  .IP
>  .IP "\fB--suffix=SUFFIX\fP"
>  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.
>  .IP
>  .IP "\fB-u, --update\fP"
>  This forces rsync to skip any files for which the
> - --------------------------- snip -------------------------------
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
> 
> iD8DBQE8yJa472vu22ltWBERAvOIAJ9crT1Nt5qQWUJWMclVM2UVgghlqACfS/pK
> Ya55fnKf2sA9mBctC32IDHA=
> =c9MR
> -----END PGP SIGNATURE-----
> 
> 




More information about the rsync mailing list