Fast incremental backup algorithm using RSYNC
That seems to work but I'm wondering if anyone can come up with a simpler, more efficient algorithm or add any ideas for a better way of accomplishing this.


I think so. Use a naming scheme with a common prefix, and a variable suffix depending on the period, for example:


Hourly backups for 24 hours: hourly-$(date +%H).gz, results in:


hourly-00.gz
hourly-01.gz
hourly-02.gz
... and so on until hourly-23.gz after which it starts over from hourly-00.gz

Daily backups for 1 week: daily-$(date +%a).gz, results in:


daily-Sun.gz
daily-Mon.gz
daily-Tue.gz
... and so on until daily-Sat.gz, after which it starts over

Weekly backups for 1 month: weekly-$(($(date +%W) % 4)).gz, results in:


weekly-00.gz
weekly-01.gz
weekly-02.gz
weekly-03.gz after which it starts over from weekly-00.gz



You'll never have to delete anything. You will have the same set of files,
and rsync (with appropriate parameters) will copy only the changed ones.

As for the posted code,
the single biggest problem is the duplicate calls to $(date ...) with the same parameters:


Inefficient: multiple unnecessary process executions
Bad practice: duplicated logic
Unnecessary and error prone: the multiple calls to $(date +%w) (for example) probably expect to get the same result. So there should be only one call, saved in a variable. If the day happens to turn between two calls, may have a nasty bug, and in any case it's completely unintended situation.