During Final Tests of the previous script some bugs came up. Bug were fixed and some minor update to the rotation engine were done. Updated code is attacched below.
[...] you might want to put all variable assignments (especially the ones that touch disks) in their own file which will be the main file people read. For instance, I don't want to have to scroll 200 lines to see where the logs are going. Same for the actual Rsync command as well and how it's called.
thanks for the advices. I was thinking about spread the code in multiple files using functions to separate tasks and I will certainly do that in the future.
[...] what if I want to use the script arbitrarily in a one-off fashion? If I did, that would kind of suggest to detach the cron logic
I don't think about detaching the cron logic because the script was written for this purpose. If I need to sync to folders in a one-off manner I simply run an rsync job from the command line.
Being that I haven't used "hdparm", I have a honest question: How do you know this succeeds? [...] Again though, I've never used it so I don't know if any switch can detect status, so maybe -y always works.
I'm not completely sure that hdparm -y always work but I made some tests and (if the disk support power management functionality, i.e. hdparm -C returns a valid answer) the command works regardless of the mount status of the drive. Being that said you're right and bacause there is no 100% guarantee that umount and hdparm -y works I have inserted conditional tests also for them.
About the "testing" matter I'm completely agree with Adoby . I don't reccomend to anyone to use my-script without analyzing & understand it and certainly I don't mean that one cannot use the ready-to-use solutions present.
I want that the backups are done following exactly my needs ( custom logs, naming convention...) and I think that the best way of doing it it's via a custom script.
About the reliability of that solution I agree that the strategy should be based on something well tested but once the custom rotation engine is validated I don't have any doubt about the reliability of the script because it simply run rsync (whose reliability is out of discussion).