Created attachment 741294 [details, diff] Patch - Debian Bug #901156 Please, apply the attached patch, to make rsnapshot more robust: There is a bug with rsnapshot, see debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901156 ---- credits to go to: Osamu Problem: the robustness of rsnapshot program under desktop environment when cron is not always running and "beta" may be invoked consecutively without invoking "alpha". (I am using Debian/stable now but the version in testing/unstable is the same) How to re-produce problem: Let me present a simple manual invocation case as below (No cron/anacron/systemd.timer...): With /etc/rsnapshot.conf having: --- retain alpha 6 retain beta 7 retain gamma 4 --- Let's invoke: --- $ sudo rsnapshot alpha --- Invoking this 6 times will create: /var/cache/rsnapshot/alpha.0/ /var/cache/rsnapshot/alpha.1/ /var/cache/rsnapshot/alpha.2/ /var/cache/rsnapshot/alpha.3/ /var/cache/rsnapshot/alpha.4/ /var/cache/rsnapshot/alpha.5/ So far, this looks good. Then, let's invoke: --- $ sudo rsnapshot beta --- Invoking this will create: /var/cache/rsnapshot/alpha.0/ /var/cache/rsnapshot/alpha.1/ /var/cache/rsnapshot/alpha.2/ /var/cache/rsnapshot/alpha.3/ /var/cache/rsnapshot/alpha.4/ /var/cache/rsnapshot/beta.0/ So far still good. Let's suppose to invoke the following again and see the result: --- $ sudo rsnapshot beta /var/cache/rsnapshot/alpha.5 not present (yet), nothing to copy --- This message is true but the result is a bit unexpected: /var/cache/rsnapshot/alpha.0/ /var/cache/rsnapshot/alpha.1/ /var/cache/rsnapshot/alpha.2/ /var/cache/rsnapshot/alpha.3/ /var/cache/rsnapshot/alpha.4/ /var/cache/rsnapshot/beta.1/ Why beta.0 is missing ??? What happens is delete and rotate actions for "beta" is performed then it fails to move file from "alpha.5" to "beta.0". Rotating without new data added to "*.0" is bad. It should not do this delete and rotate actions if "alpha.5" isn't there. I am afraid this problem may be the root cause of many unexpected results under non-optimal invocation of rsnapshot. https://bugs.debian.org/523923 https://bugs.debian.org/573254 Backup script should be robust ;-) Solution proposal: Let's check situation with: -d "$config_vars{'snapshot_root'}/$prev_interval.$prev_interval_max") If not exist, "delete" and "rotate" should be skipped. See attached patch file (patch -p0) for exact detail. This may be better to be addressed by the upstream. ---- I reworked the patch (see attached), so it works with: /etc/portage/patches/app-backup/rsnapshot/rsnapshot-robust-debian_bug_#901156.patch
One more thing: the patch works also on version 1.4.4 which isn't in the tree, yet.