[SOLVED] PMG Backup - delete old backups

ananiasfilho

Active Member
Nov 20, 2019
27
29
33
44
Hello All!
We have a cron job that runs all night a backup task
# Cron - All days
0 20 * * * /usr/bin/pmgbackup backup > /dev/null 2>&1

All backups stored on /var/lib/pmg/backup
We have a backup/rsync procedure that run it to external storage place.

But, i have not found a solution to delete backups right on PMG. I can only remove old backups from GUI:
Configuration -> Backup/Restore -> Select 1 backup -> Remove -> Confirm

The question:
How to delete backups older than 7 days?

Observations:
- pmgbackup have no option to delete backups from command line (CLI)
- GUi have no option to delete multiples backups.

thank you!
 
The backup listings are based solely on the directory contents of /var/lib/pmg/backup - meaning if you delete the file there this is enough to make it vanish in PMG.

For your use-case you could simply delete the files after the rsync - to do so based on file-age you can use find (`man find`) - e.g. (without testing - so verify this before putting it in production):
Code:
find /var/lib/pmg/backup -iname 'pmg-backup_*.tgz' -mtime +7 -delete

I hope this helps!
 
Hello Ivanov! Thanks again for fast reply!
Im doing this exactly procedure today.
PMG dont store backup informations on database or other place? My fear is just delete backup files and keep informations in others places as database.

Maybe possíble to open a feature request on Proxmox Mail Gateway asking to new features:
1 - select multiples lines
2 - Option to schedule backcup (as cron)
3 - Optioin to keep only X days backups

Again, thank you very much!
 
PMG dont store backup informations on database or other place? My fear is just delete backup files and keep informations in others places as database.
yes - it's only the files in the directory - check the souce-code:
https://git.proxmox.com/?p=pmg-api....e28f23956ec7e0ff64e77ea04a333a53;hb=HEAD#l189

Maybe possíble to open a feature request on Proxmox Mail Gateway asking to new features:
1 - select multiples lines
2 - Option to schedule backcup (as cron)
3 - Optioin to keep only X days backups

We did recently implement an integration with Proxmox Backup Server where you can configure such things (and even more, like optional encryption) - so you could use that.

I hope this helps!
 
yes - it's only the files in the directory - check the souce-code:
https://git.proxmox.com/?p=pmg-api....e28f23956ec7e0ff64e77ea04a333a53;hb=HEAD#l189
Great! I have checked source code and you are right!
We did recently implement an integration with Proxmox Backup Server where you can configure such things (and even more, like optional encryption) - so you could use that.

I hope this helps!
In my opinion, its ok if you have PBS on your infrastructure, but not if you have only one PMG - most common case of our customers (We are Proxmox partner and see it all days).
Example: many customers have PMG installed over Debian in a cloud (AWS, OVH, Scaleway or Digital Ocean) as single Mail Gateway and have a external FTP/RSYNC server to backup and don't need purchase another Server to install and do maintenance of PBS. I Agree about min. 2 PMG and a PBS, but its not the real scenario of most of little companies.

So, a single checkbox to select old backups or include function to pmgbackup delete files older than X days will be good. Sure, If possible.

Again, thank you for fast reply!
 
Example: many customers have PMG installed over Debian in a cloud (AWS, OVH, Scaleway or Digital Ocean) as single Mail Gateway and have a external FTP/RSYNC server to backup
That's a fine setup - but they need to configure the rsync/ftp/.. upload via CLI in a cronjob anyways - so I don't see the problem in adding a `find` there as well.

Regarding the selection of multiple backups for deletion via GUI - I do see that it would be a better user experience - if you like please open an enhancement request for that at https://bugzilla.proxmox.com (it will not be our top priority and no promises on when/if it will get implemented - but at least we have it in the proper place (where others can also say that they would like to see it)

Thanks!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!