# How to automatically remove backup cron pods?

**URL:** <https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217>\
**Category:** Percona Operator for MySQL\
**Created:** [February 21, 2023, 9:57am UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217 "2023-02-21T09:57:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![b602fa9c](https://avatars.discourse-cdn.com/v4/letter/b/6bbea6/32.png) [@b602fa9c](https://forums.percona.com/u/b602fa9c)\
**Post date:** [February 21, 2023, 9:57am UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217/1 "2023-02-21T09:57:52Z")

</div>

Currently when a backup job completes the pod is left in “Completed” status. In an environment where backups have to be kept for a long time the number of these pods build up and become a pain when using kubectl for other tasks.

Is there any way to have these pods be automatically removed after some time but keep the pxc-backup resource? Potentially by setting “.spec.ttlSecondsAfterFinished” on the job ([Automatic Cleanup for Finished Jobs | Kubernetes](https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/))

I couldn’t see any way to set that in the operator.

> <https://github.com/percona/percona-xtradb-cluster-operator/blob/main/pkg/pxc/backup/job.go#L41>

---

<div class="post-metadata">

**Author:** ![Slava\_Sarzhan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/slava_sarzhan/32/3196_2.png) [@Slava\_Sarzhan](https://forums.percona.com/u/Slava_Sarzhan)\
**Post date:** [February 21, 2023, 4:56pm UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217/2 "2023-02-21T16:56:19Z")

</div>

@b602fa9c Do you use keep option [percona-xtradb-cluster-operator/cr.yaml at main · percona/percona-xtradb-cluster-operator · GitHub](https://github.com/percona/percona-xtradb-cluster-operator/blob/main/deploy/cr.yaml#L603) in CR?

---

<div class="post-metadata">

**Author:** ![b602fa9c](https://avatars.discourse-cdn.com/v4/letter/b/6bbea6/32.png) [@b602fa9c](https://forums.percona.com/u/b602fa9c)\
**Post date:** [February 28, 2023, 4:48pm UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217/3 "2023-02-28T16:48:25Z")

</div>

Yes we set keep to 0

---

<div class="post-metadata">

**Author:** ![Slava\_Sarzhan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/slava_sarzhan/32/3196_2.png) [@Slava\_Sarzhan](https://forums.percona.com/u/Slava_Sarzhan)\
**Post date:** [February 28, 2023, 5:01pm UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217/4 "2023-02-28T17:01:12Z")

</div>

In this case you disabled it. If you want to keep e.g. last 5 backups you need to set it in 5 and all jobs will be cleaned up as well .

---

<div class="post-metadata">

**Author:** ![b602fa9c](https://avatars.discourse-cdn.com/v4/letter/b/6bbea6/32.png) [@b602fa9c](https://forums.percona.com/u/b602fa9c)\
**Post date:** [March 13, 2023, 11:40am UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217/5 "2023-03-13T11:40:46Z")

</div>

I want to keep the backups but not the backup jobs

---

<div class="post-metadata">

**Author:** ![jackieh](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jackieh](https://forums.percona.com/u/jackieh)\
**Post date:** [July 5, 2023, 9:58pm UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217/6 "2023-07-05T21:58:35Z")

</div>

Hi b602fa9c, I am running into the same problem, where failed or succeeded jobs linger. I also have the ‘keep’ option set, but I believe you are right that this is the retention of backups on the storage destination.

Did you ever get an answer on how to solve this problem?

---

<div class="post-metadata">

**Author:** ![b602fa9c](https://avatars.discourse-cdn.com/v4/letter/b/6bbea6/32.png) [@b602fa9c](https://forums.percona.com/u/b602fa9c)\
**Post date:** [July 20, 2023, 1:48pm UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217/7 "2023-07-20T13:48:53Z")

</div>

> [@jackieh](#):
>
> but I believe you are right that this is the retention of backups on the

No, I’m still looking for a solution to this.

---

<div class="post-metadata">

**Author:** ![elie\_mouawad](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/elie_mouawad/32/12569_2.png) [@elie\_mouawad](https://forums.percona.com/u/elie_mouawad)\
**Post date:** [September 2, 2023, 9:48pm UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217/8 "2023-09-02T21:48:49Z")

</div>

+1 on this - ttlSecondsAfterFinished is a good idea

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [September 4, 2023, 7:23am UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217/9 "2023-09-04T07:23:01Z")

</div>

@elie_mouawad what would be the best default for this?

---

<div class="post-metadata">

**Author:** ![b602fa9c](https://avatars.discourse-cdn.com/v4/letter/b/6bbea6/32.png) [@b602fa9c](https://forums.percona.com/u/b602fa9c)\
**Post date:** [October 31, 2023, 9:20am UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217/10 "2023-10-31T09:20:59Z")

</div>

Hi @Sergey_Pronin, is this feature likely to be implemented? I would suggest 86400 as a default.

---

<div class="post-metadata">

**Author:** ![Slava\_Sarzhan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/slava_sarzhan/32/3196_2.png) [@Slava\_Sarzhan](https://forums.percona.com/u/Slava_Sarzhan)\
**Post date:** [December 7, 2023, 8:06pm UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217/11 "2023-12-07T20:06:11Z")

</div>

> [@elie\_mouawad](#):
>
> ttlSecondsAfterFinished

@b602fa9c We have a task about this issue [[K8SPXC-1214] Add option to automatically cleanup jobs and associated pods - Percona JIRA](https://jira.percona.com/browse/K8SPXC-1214) . I included it to the next PXCO release.

---

<div class="post-metadata">

**Author:** ![bljurg\_geiwn](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/bljurg_geiwn/32/18297_2.png) [@bljurg\_geiwn](https://forums.percona.com/u/bljurg_geiwn)\
**Post date:** [October 13, 2024, 6:23am UTC](https://forums.percona.com/t/how-to-automatically-remove-backup-cron-pods/20217/12 "2024-10-13T06:23:50Z")

</div>

> [@elie\_mouawad](#):
>
> ttlSecondsAfterFinished

Is this available for use in any version?
