3

Is there a way to automatically cleanup backup files ansible creates when useing e.g. the copy or template modules, or to keep the last three backup files for example?

Ansible file backups from template task

Andre
  • 39
  • 4
  • 7
    What have you tried so far? – Klaus D. Sep 24 '21 at 12:43
  • 2
    The subject was different (restore a backup file) but you will find some ideas (list files, etc...) to possibly acheive your requirement in [this answer](https://stackoverflow.com/a/65368712/9401096) – Zeitounator Sep 24 '21 at 13:27
  • I mean to cleanup Backupfiles which are created by the backup: yes option. Is there an idea for a task to remove the backup files and keep the last three on every run? – Andre Sep 24 '21 at 15:33

1 Answers1

1

I've decided to create my own utility for this as any other way would require extensive Ansible scripting (which in my opinion beats the purpose of Ansible).

https://github.com/moudsen/cleanansiblebackups

Hoppa
  • 11
  • 1