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

Timestamp-pattern no such group #26

Closed
Grounz opened this issue Apr 9, 2020 · 3 comments
Closed

Timestamp-pattern no such group #26

Grounz opened this issue Apr 9, 2020 · 3 comments

Comments

@Grounz
Copy link

Grounz commented Apr 9, 2020

Hi,

I want use timestamp-pattern option for extract timestamp from this above filename:

prometheus-grafana-production-09-04-2020.tar.gz

So i use this regex, that i have test on regex101.com :

r'''(?P<day>\d{2})-(?P<month>\d{2})-(?P<year>\d{4})'''

and their groups day, month and year are correcty captured in regex101.

So when i test on my backup server, rotate-backups says:

2020-04-09 16:14:22 host property_manager[26040] SPAM RotateBackups.timestamp_pattern reporting assigned or cached value (<_sre.SRE_Pattern object at 0x7f55def01df0>) ..
2020-04-09 16:14:22 host rotate_backups[26040] DEBUG Failed to match time stamp in filename: prometheus-grafana-production-09-04-2020.tar.gz
2020-04-09 16:14:22 host property_manager[26040] SPAM Location.ssh_alias reporting assigned or cached value (None) ..
2020-04-09 16:14:22 host property_manager[26040] SPAM Location.directory reporting assigned or cached value ('/home/backup/externalBackupTransfert/prometheus-grafana/production') ..
2020-04-09 16:14:22 host rotate_backups[26040] INFO No backups found in /home/backup/externalBackupTransfert/prometheus-grafana/production.

and in this directory i have a one file named; prometheus-grafana-production-09-04-2020.tar.gz

I don't understand for why this timestamp is not interpreted by rotate-backups, can you help me ?

@Ganfoud
Copy link

Ganfoud commented Apr 10, 2020

Hi
I have (I think) the same issue:

2020-04-10 09:57:44 athena rotate_backups.cli[14008] INFO Performing a dry run (because of -n option) ..
2020-04-10 09:57:44 athena rotate_backups.cli[14008] VERBOSE Rotation scheme defined on command line: {'daily': 7, 'weekly': 2, 'monthly': 2}
2020-04-10 09:57:44 athena rotate_backups.cli[14008] VERBOSE Selected 1 location based on command line arguments:
2020-04-10 09:57:44 athena rotate_backups.cli[14008] VERBOSE  1. /DiskStation/xxx/sites_web
2020-04-10 09:57:44 athena rotate_backups[14008] VERBOSE No configuration found for /DiskStation/xxx/sites_web.
2020-04-10 09:57:44 athena rotate_backups[14008] INFO Scanning /DiskStation/xxx/sites_web for backups ..
2020-04-10 09:57:44 athena rotate_backups[14008] VERBOSE Confirmed that location exists: /DiskStation/xxx/sites_web
2020-04-10 09:57:45 athena rotate_backups[14008] VERBOSE Confirmed that location is readable: /DiskStation/xxx/sites_web
Traceback (most recent call last):
  File "/usr/local/bin/rotate-backups", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/rotate_backups/cli.py", line 338, in main
    program.rotate_backups(location)
  File "/usr/local/lib/python3.7/dist-packages/rotate_backups/__init__.py", line 548, in rotate_backups
    sorted_backups = self.collect_backups(location)
  File "/usr/local/lib/python3.7/dist-packages/rotate_backups/__init__.py", line 656, in collect_backups
    timestamp=self.match_to_datetime(match),
  File "/usr/local/lib/python3.7/dist-packages/rotate_backups/__init__.py", line 681, in match_to_datetime
    value = match.group(component)
IndexError: no such group

the files in the directory are named with this template: backup-4.9.2020_19-30-12.tar.gz

@xolox
Copy link
Owner

xolox commented May 18, 2020

Thanks for the bug report, this is fixed in release 8.1!

@Ganfoud
Copy link

Ganfoud commented May 18, 2020

Tested and approved, it works now, thanks for the update!

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

No branches or pull requests

3 participants