cskoglun / ciscodnacbackupctl

Other
15 stars 2 forks source link

Support for keep period instead of numbers #5

Closed fatman00 closed 3 years ago

fatman00 commented 3 years ago

It would be great if the script supported the retention period in days instead of number of backups.

ciscodnacbackupctl daemon start --keep-days 30

robertcsapo commented 3 years ago

@fatman00 Would it keep all backups within 30 days, giving the specific time the script is executing?

Example: today - 30 days, everything beyond is purged.

fatman00 commented 3 years ago

@robertcsapo Yes, everything older than 30 days is purged regularly

robertcsapo commented 3 years ago

Added this to version 0.2.5

Use the same syntax, but add d for days.

See example below

ciscodnacbackupctl purge --keep 60d
BACKUP_ID                             BACKUP_SIZE    COMPATIBLE    DESCRIPTION    END_TIMESTAMP        START_TIMESTAMP      STATUS
295deee5-391a-4a6d-8505-71f324b4af52  17G            TRUE          dnac-weekly    2021-04-18 01:07:14  2021-04-18 01:00:44  SUCCESS
cfae7a5e-a85e-4c0b-b97a-9db620ecd2d6  17G            TRUE          dnac-weekly    2021-04-11 01:07:28  2021-04-11 01:01:10  SUCCESS
5553eebd-8b0b-465d-bfb7-d392d458873d  17G            TRUE          dnac-weekly    2021-04-04 01:12:25  2021-04-04 01:00:51  SUCCESS
Warning: Confirm if you want to delete these backups (y/n): y
Deleting... (this could take a while - as it's synchronous API calls)
Deleted backup (backup_id='295deee5-391a-4a6d-8505-71f324b4af52')
Deleted backup (backup_id='cfae7a5e-a85e-4c0b-b97a-9db620ecd2d6')
Deleted backup (backup_id='5553eebd-8b0b-465d-bfb7-d392d458873d')
Success: Backups (3) deleted ['295deee5-391a-4a6d-8505-71f324b4af52', 'cfae7a5e-a85e-4c0b-b97a-9db620ecd2d6', '5553eebd-8b0b-465d-bfb7-d392d458873d']

ciscodnacbackupctl purge --keep 60d   
No backup to delete