Ercolino de spiacico
2011-Nov-27 16:47 UTC
Delete file on destination only if source was delete at least X days before.
Hello everybody, I've been looking for a way to use rsync with the --del option but checking the data of the file as well. What I'm after is a way to backup NAS1 to NAS2, literally copying everything, but asking rsync not to delete data on NAS2 not present on NAS1 if the source was removed less than e.g. 60 days ago. Perhaps a cross checking between the file/dir date and the system date or something? The reason for this it's pretty obvious, how many time did we delete files by mistake? So a X days buffer would work well in my case. At the moment I have cron 2 jobs, one copying (running every day) and the other copying+delete (on the 1st of the month only), it somehow does the job but there's a risk to delete something on the 31st and not have a backup available any more the very next day. Thanks!
Kevin Korb
2011-Nov-27 17:47 UTC
Delete file on destination only if source was delete at least X days before.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Rsync has absolutely no knowledge of when a file was deleted. Perhaps you are looking for something like --backup and --backup-dir to temporarily preserve files instead of deleting them (then deleting them with a simple rm -rf later)? Or maybe you should consider an rsync --link-dest based backup system instead of a simple mirroring that will allow you to keep many complete old backups with minimal increase in disk space usage. On 11/27/11 11:47, Ercolino de spiacico wrote:> Hello everybody, > > I've been looking for a way to use rsync with the --del option but > checking the data of the file as well. > > What I'm after is a way to backup NAS1 to NAS2, literally copying > everything, but asking rsync not to delete data on NAS2 not present > on NAS1 if the source was removed less than e.g. 60 days ago. > > Perhaps a cross checking between the file/dir date and the system > date or something? > > The reason for this it's pretty obvious, how many time did we > delete files by mistake? So a X days buffer would work well in my > case. > > At the moment I have cron 2 jobs, one copying (running every day) > and the other copying+delete (on the 1st of the month only), it > somehow does the job but there's a risk to delete something on the > 31st and not have a backup available any more the very next day. > > Thanks!- -- ~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~ Kevin Korb Phone: (407) 252-6853 Systems Administrator Internet: FutureQuest, Inc. Kevin at FutureQuest.net (work) Orlando, Florida kmk at sanitarium.net (personal) Web page: http://www.sanitarium.net/ PGP public key available on web site. ~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~ -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk7Sd54ACgkQVKC1jlbQAQduCgCdFzli8OmdUn8d8jz48TDXjN2c zE4AnjZjXr77OW2T8yjAKt5Gt2k3He9H =OtIc -----END PGP SIGNATURE-----