Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weekly not working correctly at start of year #31

Open
cpresse opened this issue Mar 7, 2021 · 1 comment · May be fixed by #35
Open

weekly not working correctly at start of year #31

cpresse opened this issue Mar 7, 2021 · 1 comment · May be fixed by #35

Comments

@cpresse
Copy link

cpresse commented Mar 7, 2021

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: [email protected]
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:

@olli-tech
Copy link

I can confirm that. Script work OK (thank you) but under the condition described above it matches 20210101 as weekly backup, and losing therefore one of the weekly backups

Command:
rotate-backups --dry-run --syslog=true --relaxed --daily=28 --weekly=5 --monthly=12 --yearly=always .

Expecting to keep 20210208-223001, instead it keeps 20210101-223001

Output:

`2021-03-10 13:00:02 hostname rotate_backups.cli[1016] INFO Performing a dry run (because of --dry-run option) ..
2021-03-10 13:00:02 hostname rotate_backups[1016] INFO Scanning . for backups ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Found 159 timestamped backups in .
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20200804-223001 (matches 'monthly' and 'yearly' retention periods) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200807-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200810-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200813-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200816-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200819-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200822-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200825-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200828-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200831-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20200903-223001 (matches 'monthly' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200906-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200909-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200912-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200915-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200916-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200918-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200921-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200924-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200927-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20200930-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20201001-223001 (matches 'monthly' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201003-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201006-223002 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201009-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201012-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201015-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201018-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201021-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201024-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201027-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201030-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20201102-223001 (matches 'monthly' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201104-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201105-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201106-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201107-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201108-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201109-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201110-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201111-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201112-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201113-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201114-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201115-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201116-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201117-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201118-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201119-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201120-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201121-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201122-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201123-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201124-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201125-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201126-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201127-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201128-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201129-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201130-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20201201-223001 (matches 'monthly' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201202-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201203-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201204-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201205-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201206-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201207-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201208-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201209-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201210-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201211-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201212-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201213-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201214-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201215-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201216-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201217-223002 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201218-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201219-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201220-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201221-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201222-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201223-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201224-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201225-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201226-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201227-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201228-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201229-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201230-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20201231-223001 ..


PROBLEM HERE
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210101-223001 (matches 'weekly', 'monthly' and 'yearly' retention periods) ..


2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210102-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210103-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210104-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210105-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210106-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210107-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210108-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210109-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210110-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210111-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210112-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210113-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210114-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210115-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210116-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210117-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210118-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210119-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210120-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210121-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210122-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210123-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210124-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210125-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210126-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210127-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210128-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210129-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210130-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210131-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210201-223001 (matches 'monthly' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210202-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210203-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210204-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210205-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210206-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210207-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210208-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Deleting 20210209-223001 ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210210-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210211-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210212-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210213-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210214-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210215-223001 (matches 'daily' and 'weekly' retention periods) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210216-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210217-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210218-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210219-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210220-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210221-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210222-223001 (matches 'daily' and 'weekly' retention periods) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210223-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210224-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210225-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210226-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210227-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210228-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210301-223001 (matches 'daily', 'weekly' and 'monthly' retention periods) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210302-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210303-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210304-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210305-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210306-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210307-223001 (matches 'daily' retention period) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210308-223001 (matches 'daily' and 'weekly' retention periods) ..
2021-03-10 13:00:03 hostname rotate_backups[1016] INFO Preserving 20210309-223001 (matches 'daily' retention period) ..
`

Version:
pip show rotate-backups Name: rotate-backups Version: 8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants