This is again a script that people could write easily if they understood some shell scripting, but it is quite well implemented with logging and all and maybe spares a couple of minutes/hours of your time.
You should use it with crontab on a daily basis. For details take a look at the desc. of the MySQL backup script.
The "days" variable was not used properly in the cleanup code, find ... -mtime +${days} returned ${days}+2 items. Replaced it with an ls -1t + tail -n +$((days+1)) combo.
In case the directory specified by the "backupdir" variable was not writable, the script still tried to log an error message in that directory.
The days variable can now be specified for each do_backup invocation separately. Note that this breaks backward compatibility if you used previously the third option of do_backup for specifying find parameters. If that's the case, you've to insert now a - sign before the find parameter list so the script'll use the global days value for the given do_backup invocation (as it did before).
Comments
Filesystem backup v1.3.0
nice
(with "-n +19") to limit the CPU resources consumed by the bzip2 compressionFilesystem backup v1.4.0
find ... -mtime +${days}
returned${days}
+2 items. Replaced it with anls -1t
+tail -n +$((days+1))
combo.Filesystem backup v1.5.0
days
variable can now be specified for eachdo_backup
invocation separately. Note that this breaks backward compatibility if you used previously the third option ofdo_backup
for specifyingfind
parameters. If that's the case, you've to insert now a-
sign before thefind
parameter list so the script'll use the globaldays
value for the givendo_backup
invocation (as it did before).