remove files older than ~6 months
authorMatthias Förste <foerste@schlittermann.de>
Fri, 04 Dec 2015 14:50:26 +0100
changeset 19 8fdfcd6613e1
parent 18 6834269f84c4
child 20 af704a990f42
remove files older than ~6 months
ldap-backup
--- a/ldap-backup	Fri Dec 04 14:33:48 2015 +0100
+++ b/ldap-backup	Fri Dec 04 14:50:26 2015 +0100
@@ -8,6 +8,8 @@
 
 ME=$(basename $0)
 cf=/etc/$ME.conf
+basename='ldap'
+days='180'
 
 if test -t 0; then
 	# terminal/interactive
@@ -29,7 +31,7 @@
 	&& trap "rm -rf $tmpdir" EXIT
 
 cd $tmpdir
-dir="ldap.$tag"
+dir="$basename.$tag"
 mkdir "$dir"
 
 # save the config db
@@ -48,3 +50,5 @@
 	   "$destination"/"$dir".tar.gz
 
 done
+
+find "$destination" -name "$basename"'.*'.tar.gz -mtime "+$days" -print0 | xargs -r0 rm