diff options
| author | Robert Bruce Park <r@robru.ca> | 2013-11-15 10:35:04 -0800 |
|---|---|---|
| committer | Robert Bruce Park <r@robru.ca> | 2013-11-15 10:35:04 -0800 |
| commit | 9b9a564447cc6bf1aa99b65e57c3ecafefe9aca4 (patch) | |
| tree | 497fa401c8311e1c8021ed28eb1f7ec8de879590 | |
| parent | ae7998025a80d1119361d5b0a948063856bc380d (diff) | |
More robust date handling.
Previously the date handling expiry logic had a bug where if you had
backups that were a year apart to the day, it wouldn't notice the
difference in year and only notice that the month was the same, and
expire the older one (eg, if you had a backup on 2012-04-01 and
another on 2013-04-01, it'd delete the one from 2012. This commit
makes it compare the full date string instead of just the month, so
that it more robustly keeps older backups.
| -rw-r--r-- | rsync_tmbackup.sh | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index 1bad059..10ec4f7 100644 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -190,11 +190,11 @@ while [ "1" ]; do elif [ $stamp -ge $KEEP_DAILIES_DATE ]; then # Delete all but the most recent of each day. - [ ${date:8:2} -eq ${prev:8:2} ] && fn_expire_backup "$fname" + [ "${date:0:10}" == "${prev:0:10}" ] && fn_expire_backup "$fname" else # Delete all but the most recent of each month. - [ ${date:5:2} -eq ${prev:5:2} ] && fn_expire_backup "$fname" + [ "${date:0:7}" == "${prev:0:7}" ] && fn_expire_backup "$fname" fi prev=$date |
