Q&A: How can I change the retention time for backups?

Question

How can I change the retention time for backups?

Answer

Every day, univention stores automatic backups from ldap and samba in /var/univention-backup.
These files can take much filespace, so should be cleaned up from time to time To do this automatically define a retention time via ucr.
The retention time is defined as ucr-variable in days.

For example, the following command changes it to 365 days

root@example:~# ucr set backup/clean/max_age=365
Setting backup/clean/max_age

For information here is the specification of the variable

ucr info backup/clean/max_age
backup/clean/max_age: <empty>
 Automatic deletion of backup-files in /var/univention-backup/, of files older than backup/clean/max_age. If unset, no files are deleted. If less than backup/clean/min_backups backup-files exist, no files are deleted.
 Categories: service-misc

You can also define

backup/clean/min_backups: <empty>
 Automatic deletion of backup-files in /var/univention-backup/: if backup/clean/max_age is set and less than backup/clean/min_backups backup-files exist, no files are deleted. Defaults to 10.

samba4 backups

in /var/univention-backup/samba
The ucr variable does not work for the samba4 backups. These backups are done by cron.
So you can pass the value via ucr variable samba4/backup/cron/options

 less /etc/cron.d/univention-samba4-backup
# Warning: This file is auto-generated and might be overwritten by
#          univention-config-registry.
#          Please edit the following file(s) instead:
# Warnung: Diese Datei wurde automatisch generiert und kann durch
#          univention-config-registry ueberschrieben werden.
#          Bitte bearbeiten Sie an Stelle dessen die folgende(n) Datei(en):
#
#       /etc/univention/templates/files/etc/cron.d/univention-samba4-backup
#

SHELL=/bin/sh   
PATH=/sbin:/bin:/usr/sbin:/usr/bin

0 3 * * * root /usr/sbin/univention-samba4-backup
/usr/sbin/univention-samba4-backup --help
univention-samba4-backup: backups the samba provision directory

Syntax:
    univention-samba4-backup [options]

Options:
    --help|-h                   display this message
    --where|-w <DIR>            backup directory
    --from-where|-f <DIR>       samba provision directory
    --days|-d <INT>             retention period in days
 ucr info  samba4/backup/cron/options
samba4/backup/cron/options: <empty>
 This variable allows the configuration of options for the univention-samba4-backup started by cron.
 Categories: service-samba
ucr set samba4/backup/cron/options='-d 365'
2 Likes
Mastodon