Hi folks,
we would like your feedback on a new option we have implemented. We
would like to know whether it should be merged into the CVS
tree. Perhaps one of the rsync developers can have a look at the code,
improve it where necessary, and committ it to CVS.
The name of the option is "--delete-mdays=DAYS" and it works in
conjunction with the option "--delete." It modifies the behaviour of
"--delete" so that files not present on the sender are only deleted on
the receiver if they are at least "DAYS" days old (modification
time). This is useful e.g. when mails are being backed up, where a
fall-back copy of the message should be available for "DAYS" days.
We modfied "options.c" and "receiver.c" from version 2.6.3.
Best regards,
Marko Riedel
*** options.c Tue Oct 5 15:46:00 2004
--- /tmp/rsync-2.6.3/options.c Thu Sep 23 19:39:05 2004
***************
*** 52,62 ****
int cvs_exclude = 0;
int dry_run = 0;
int local_server = 0;
int ignore_times = 0;
int delete_mode = 0;
- int delete_mdays = -1;
int delete_excluded = 0;
int one_file_system = 0;
int protocol_version = PROTOCOL_VERSION;
int sparse_files = 0;
int do_compression = 0;
--- 52,61 ----
***************
*** 263,273 ****
rprintf(F," -e, --rsh=COMMAND specify the remote
shell\n");
rprintf(F," --rsync-path=PATH specify path to rsync on the
remote machine\n");
rprintf(F," --existing only update files that already
exist\n");
rprintf(F," --ignore-existing ignore files that already exist
on receiving side\n");
rprintf(F," --delete delete files that don't
exist on the sending side\n");
- rprintf(F," --delete-mdays=DAYS mtime must be > DAYS ago
when deleting\n");
rprintf(F," --delete-excluded also delete excluded files on
the receiving side\n");
rprintf(F," --delete-after receiver deletes after
transferring, not before\n");
rprintf(F," --ignore-errors delete even if there are I/O
errors\n");
rprintf(F," --max-delete=NUM don't delete more than NUM
files\n");
rprintf(F," --partial keep partially transferred
files\n");
--- 262,271 ----
***************
*** 337,347 ****
{"delete", 0, POPT_ARG_NONE, &delete_mode, 0, 0,
0 },
{"existing", 0, POPT_ARG_NONE, &only_existing, 0,
0, 0 },
{"ignore-existing", 0, POPT_ARG_NONE,
&opt_ignore_existing, 0, 0, 0 },
{"delete-after", 0, POPT_ARG_NONE, 0,
OPT_DELETE_AFTER, 0, 0 },
{"delete-excluded", 0, POPT_ARG_NONE, 0,
OPT_DELETE_EXCLUDED, 0, 0 },
- {"delete-mdays", 0, POPT_ARG_INT, &delete_mdays, 0, 0,
0 },
{"force", 0, POPT_ARG_NONE, &force_delete, 0, 0,
0 },
{"numeric-ids", 0, POPT_ARG_NONE, &numeric_ids, 0, 0,
0 },
{"exclude", 0, POPT_ARG_STRING, 0,
OPT_EXCLUDE, 0, 0 },
{"include", 0, POPT_ARG_STRING, 0,
OPT_INCLUDE, 0, 0 },
{"exclude-from", 0, POPT_ARG_STRING, 0,
OPT_EXCLUDE_FROM, 0, 0 },
--- 335,344 ----
***************
*** 659,675 ****
am_server ? "server" : "client");
return 0;
}
#endif
- if (delete_mdays!=-1 && delete_mdays<1){
- snprintf(err_buf, sizeof err_buf,
- "--delete-mdays needs a positive integer argument (number of days);
"
- "got %d\n", delete_mdays);
- return 0;
- }
-
if (write_batch && read_batch) {
snprintf(err_buf, sizeof err_buf,
"--write-batch and --read-batch can not be used together\n");
return 0;
}
--- 656,665 ----
***************
*** 1037,1052 ****
if (delete_after)
args[ac++] = "--delete-after";
if (force_delete)
args[ac++] = "--force";
-
- if (delete_mdays!=-1){
- if (asprintf(&arg, "--delete-mdays=%d", delete_mdays) < 0)
- goto oom;
- args[ac++] = arg;
- }
}
if (size_only)
args[ac++] = "--size-only";
--- 1027,1036 ----
*** receiver.c Tue Oct 5 15:53:39 2004
--- /tmp/rsync-2.6.3/receiver.c Tue Sep 21 11:24:06 2004
***************
*** 22,32 ****
extern int verbose;
extern int recurse;
extern int delete_after;
extern int max_delete;
- extern int delete_mdays;
extern int csum_length;
extern struct stats stats;
extern int dry_run;
extern int read_batch;
extern int batch_gen_fd;
--- 22,31 ----
***************
*** 119,147 ****
for (i = local_file_list->count-1; i >= 0; i--) {
if (max_delete && deletion_count > max_delete)
break;
if (!local_file_list->files[i]->basename)
continue;
-
if (flist_find(flist,local_file_list->files[i]) < 0) {
char *f = f_name(local_file_list->files[i]);
-
- time_t now_time = time(NULL);
- time_t mday_time = now_time-delete_mdays*24*60*60;
- time_t file_modtime = local_file_list->files[i]->modtime;
-
- if (delete_mdays!=-1 && file_modtime>mday_time){
- if(verbose)
- rprintf(FINFO,
- "not deleting %s, age %d days, need %d days\n",
- safe_fname(f),
- (int)(now_time-file_modtime)/24/60/60,
- delete_mdays);
- continue;
- }
-
-
if (make_backups && (backup_dir || !is_backup_file(f))) {
make_backup(f);
if (verbose) {
rprintf(FINFO, "deleting %s\n",
safe_fname(f));
--- 118,129 ----
--
+------------------------------------------------------------+
| Marko Riedel, EDV Neue Arbeit gGmbH, mriedel@neuearbeit.de |
| http://www.geocities.com/markoriedelde/index.html |
+------------------------------------------------------------+