View | Details | Raw Unified | Return to bug 38554 | Differences between
and this patch

Collapse All | Expand All

(-)a/base/univention-lib/debian/python-univention-lib.univention-config-registry-variables (-2 / +12 lines)
 Lines 10-12   Mehrfache Einträge müssen durch einen Doppelpunkt getrennt werden. Ist die Var Link Here 
10
Description[en]=The automatic move of file shares - configurable through the variable listener/shares/rename - is only allowed for the filesystems defined here. Multiple entries need to be separated by a colon. If the variable isn't set 'ext2/ext3:ext2:ext3:ext4:xfs:btrfs' applies.
10
Description[en]=The automatic move of file shares - configurable through the variable listener/shares/rename - is only allowed for the filesystems defined here. Multiple entries need to be separated by a colon. If the variable isn't set 'ext2/ext3:ext2:ext3:ext4:xfs:btrfs' applies.
11
Type=str
11
Type=str
12
Categories=service-misc
12
Categories=service-misc
13
- 
13
14
--
14
[backup/clean/max_age]
15
Description[en]=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.
16
Description[de]=Automatisches Löschen von Backup-Dateien in /var/univention-backup, die älter als backup/clean/max_age sind. Wenn diese Variable nicht gesetzt ist, werden keine Dateien gelöscht. Wenn weniger als backup/clean/min_backups Backup-Dateien existieren, werden keine Dateien gelöscht.
17
Type=int
18
Categories=service-misc
19
20
[backup/clean/min_backups]
21
Description[en]=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.
22
Description[de]=Automatisches Löschen von Backup-Dateien in /var/univention-backup: wenn backup/clean/max_age gesetzt ist und weniger als backup/clean/min_backups Backup-Dateien existieren, werden keine Dateien gelöscht. Standardwert ist 10.
23
Type=int
24
Categories=service-misc
15
base/univention-lib/shell/backup.sh | 54 +++++++++++++++++++++++++++++++++++++
25
base/univention-lib/shell/backup.sh | 54 +++++++++++++++++++++++++++++++++++++
16
1 file changed, 54 insertions(+)
26
1 file changed, 54 insertions(+)
17
create mode 100644 base/univention-lib/shell/backup.sh
27
create mode 100644 base/univention-lib/shell/backup.sh
(-)a/base/univention-lib/shell/backup.sh (-2 / +54 lines)
Line 0    Link Here 
0
- 
1
# Univention Common Shell Library
2
#
3
# Copyright 2017 Univention GmbH
4
#
5
# http://www.univention.de/
6
#
7
# All rights reserved.
8
#
9
# The source code of this program is made available
10
# under the terms of the GNU Affero General Public License version 3
11
# (GNU AGPL V3) as published by the Free Software Foundation.
12
#
13
# Binary versions of this program provided by Univention to you as
14
# well as other copyrighted, protected or trademarked materials like
15
# Logos, graphics, fonts, specific documentations and configurations,
16
# cryptographic keys etc. are subject to a license agreement between
17
# you and Univention and not subject to the GNU AGPL V3.
18
#
19
# In the case you use this program under the terms of the GNU AGPL V3,
20
# the program is provided in the hope that it will be useful,
21
# but WITHOUT ANY WARRANTY; without even the implied warranty of
22
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
# GNU Affero General Public License for more details.
24
#
25
# You should have received a copy of the GNU Affero General Public
26
# License with the Debian GNU/Linux or Univention distribution in file
27
# /usr/share/common-licenses/AGPL-3; if not, see
28
# <http://www.gnu.org/licenses/>.
29
30
# Clean old backups in /var/univention-backup/ that are older than
31
# backup/clean/max_age, if more than backup/clean/min_backups files exist.
32
# 1. parameter: a pattern to match files to delete via `find .. -regex ..`
33
# 2. parameter: override backup/clean/max_age (optional)
34
#
35
# Example to cleanup LDAP-backups:
36
# clean_old_backups 'ldap-backup_*.\(log\|ldif\)'
37
clean_old_backups () {
38
	local arg_pattern="$1"
39
	local arg_max_age="$2"
40
	[ -z "$arg_pattern" ] && return 1
41
	eval "$(univention-config-registry shell backup/clean/.*)"
42
43
	local backup_dir="/var/univention-backup"
44
	local pattern="$backup_dir/$arg_pattern"
45
	local max_age="${arg_max_age:-$backup_clean_max_age}"
46
47
	if [ -n "$max_age" ]; then
48
		echo find "$backup_dir" -type f -mtime "+$max_age" -regex "$pattern"
49
		local count=$(find "$backup_dir" -type f -mtime "+$max_age" -regex "$pattern" | wc -l)
50
		if [ "$count" -ge "${backup_clean_min_backups:-10}" ]; then
51
				find "$backup_dir" -type f -mtime +"$backup_clean_max_age" -regex "$pattern" -delete
52
		fi
53
	fi
54
}
1
u-ldap-backup
55
u-ldap-backup
2
--
3
management/univention-ldap/univention-ldap-backup | 3 +++
56
management/univention-ldap/univention-ldap-backup | 3 +++
4
1 file changed, 3 insertions(+)
57
1 file changed, 3 insertions(+)
(-)a/management/univention-ldap/univention-ldap-backup (-2 / +3 lines)
 Lines 30-35    Link Here 
30
# /usr/share/common-licenses/AGPL-3; if not, see
30
# /usr/share/common-licenses/AGPL-3; if not, see
31
# <http://www.gnu.org/licenses/>.
31
# <http://www.gnu.org/licenses/>.
32
32
33
. /usr/share/univention-lib/backup.sh
33
eval "$(univention-config-registry shell server/role)"
34
eval "$(univention-config-registry shell server/role)"
34
35
35
if [ "$server_role" = "domaincontroller_master" -o "$server_role" = "domaincontroller_backup" ]; then
36
if [ "$server_role" = "domaincontroller_master" -o "$server_role" = "domaincontroller_backup" ]; then
 Lines 48-51   if [ "$server_role" = "domaincontroller_master" -o "$server_role" = "domaincontr Link Here 
48
		echo "LDAP could not be dumped!" >&2
49
		echo "LDAP could not be dumped!" >&2
49
		exit 1
50
		exit 1
50
	fi
51
	fi
52
53
	clean_old_backups 'ldap-backup_.*\.\(log\|ldif\)\(\.gz\)?'
51
fi
54
fi
52
- 
53
ucr-backup
55
ucr-backup
54
--
55
base/univention-base-files/scripts/univention-config-registry-backup | 3 +++
56
base/univention-base-files/scripts/univention-config-registry-backup | 3 +++
56
1 file changed, 3 insertions(+)
57
1 file changed, 3 insertions(+)
(-)a/base/univention-base-files/scripts/univention-config-registry-backup (-2 / +3 lines)
 Lines 30-35    Link Here 
30
# /usr/share/common-licenses/AGPL-3; if not, see
30
# /usr/share/common-licenses/AGPL-3; if not, see
31
# <http://www.gnu.org/licenses/>.
31
# <http://www.gnu.org/licenses/>.
32
32
33
. /usr/share/univention-lib/backup.sh
34
33
cd /etc/univention
35
cd /etc/univention
34
TARGET="/var/univention-backup/ucr-backup_$(date +%Y%m%d).tgz"
36
TARGET="/var/univention-backup/ucr-backup_$(date +%Y%m%d).tgz"
35
touch "$TARGET"
37
touch "$TARGET"
 Lines 37-40   chmod 600 "$TARGET" Link Here 
37
chown root:root "$TARGET"
39
chown root:root "$TARGET"
38
tar cfz "$TARGET" ./base*.conf
40
tar cfz "$TARGET" ./base*.conf
39
41
42
clean_old_backups 'ucr-backup_.*\.tgz'
40
exit 0
43
exit 0
41
- 
42
u-s4-backup
44
u-s4-backup
43
--
44
services/univention-samba4/sbin/univention-samba4-backup | 7 ++++---
45
services/univention-samba4/sbin/univention-samba4-backup | 7 ++++---
45
1 file changed, 4 insertions(+), 3 deletions(-)
46
1 file changed, 4 insertions(+), 3 deletions(-)
(-)a/services/univention-samba4/sbin/univention-samba4-backup (-4 / +4 lines)
 Lines 56-61    Link Here 
56
#    - Fix retention period bug when deleting old backups ($DAYS variable
56
#    - Fix retention period bug when deleting old backups ($DAYS variable
57
#      could be set, but was ignored).
57
#      could be set, but was ignored).
58
58
59
. /usr/share/univention-lib/backup.sh
60
59
display_help() {
61
display_help() {
60
	cat <<-EOL
62
	cat <<-EOL
61
		univention-samba4-backup: backups the samba provision directory
63
		univention-samba4-backup: backups the samba provision directory
 Lines 73-79   display_help() { Link Here 
73
75
74
FROMWHERE=/var/lib/samba
76
FROMWHERE=/var/lib/samba
75
WHERE=/var/univention-backup/samba
77
WHERE=/var/univention-backup/samba
76
DAYS=365
78
DAYS=""
77
DIRS="private sysvol"
79
DIRS="private sysvol"
78
WHEN="$(date +%Y-%m-%d)"
80
WHEN="$(date +%Y-%m-%d)"
79
81
 Lines 169-173   for d in $DIRS; do Link Here 
169
	fi
171
	fi
170
done
172
done
171
173
172
find $WHERE -name "samba4_*bz2" -mtime +$DAYS -exec rm  {} \;
174
clean_old_backups 'samba/\(samba4_\|sysvol\).*.bz2' "$DAYS"
173
find $WHERE -name "sysvol\.*bz2" -mtime +$DAYS -exec rm  {} \;
174
- 

Return to bug 38554