|
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(+) |