Skip to content

weekly not working correctly at start of year #31

@cpresse

Description

@cpresse

It seems the weekly parameter is not working correctly at the start of the year.

I have these files:

2020-12-26
2021-01-02
2021-01-09
2021-01-16
2021-01-23
2021-01-30

Invoking rotate-backups with 4 weeks it skips 2021-01-09 and keeps 2021-01-02 instead. Expected behaviour was to keep 2021-01-09 and delete 2021-01-02.

Command
rotate-backups --weekly 4 ...

Output

rotate_backups[3695] INFO Found 6 timestamped backups in ...
rotate_backups[3695] INFO Deleting 2020-12-26 ..
rotate_backups[3695] INFO Preserving 2021-01-02 (matches 'weekly' retention period) ..
rotate_backups[3695] INFO Deleting 2021-01-09 ..
rotate_backups[3695] INFO Preserving 2021-01-16 (matches 'weekly' retention period) ..
rotate_backups[3695] INFO Preserving 2021-01-23 (matches 'weekly' retention period) ..
rotate_backups[3695] INFO Preserving 2021-01-30 (matches 'weekly' retention period) ..

Increasing to 5 weeks includes 2021-01-09 again.
Command
rotate-backups --weekly 5 ...

Output

2021-03-07 12:25:14 Tyrion rotate_backups[3702] INFO Found 6 timestamped backups in ...
2021-03-07 12:25:14 Tyrion rotate_backups[3702] INFO Deleting 2020-12-26 ..
2021-03-07 12:25:14 Tyrion rotate_backups[3702] INFO Preserving 2021-01-02 (matches 'weekly' retention period) ..
2021-03-07 12:25:14 Tyrion rotate_backups[3702] INFO Preserving 2021-01-09 (matches 'weekly' retention period) ..
2021-03-07 12:25:14 Tyrion rotate_backups[3702] INFO Preserving 2021-01-16 (matches 'weekly' retention period) ..
2021-03-07 12:25:14 Tyrion rotate_backups[3702] INFO Preserving 2021-01-23 (matches 'weekly' retention period) ..
2021-03-07 12:25:14 Tyrion rotate_backups[3702] INFO Preserving 2021-01-30 (matches 'weekly' retention period) ..

Using the latest version 8.1

(rotate_backups) ~/p/rotate_backups_test $ pip show rotate-backups
Name: rotate-backups
Version: 8.1
Summary: Simple command line interface for backup rotation
Home-page: https://github.com/xolox/python-rotate-backups
Author: Peter Odding
Author-email: peter@peterodding.com
License: MIT
Location: /home/cp/.venv/rotate_backups/lib/python3.8/site-packages
Requires: naturalsort, update-dotdee, python-dateutil, verboselogs, humanfriendly, six, property-manager, coloredlogs, executor, simpleeval
Required-by:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions