summaryrefslogtreecommitdiffstats
path: root/bin/reproducible_housekeeping.sh
diff options
context:
space:
mode:
authorHolger Levsen <holger@layer-acht.org>2014-10-18 22:18:15 +0200
committerHolger Levsen <holger@layer-acht.org>2014-10-18 22:47:32 +0200
commit61969fd285d66b3dd5de8694884f1791d9813f44 (patch)
tree7797c92252384d4ddc8f82ec2f0338c6314535fc /bin/reproducible_housekeeping.sh
parent15552eb58854ebf072249e1f6c6eb72b2ff62b36 (diff)
downloadjenkins.debian.net-61969fd285d66b3dd5de8694884f1791d9813f44.tar.xz
reproducible: add housekeeping job
Diffstat (limited to 'bin/reproducible_housekeeping.sh')
-rwxr-xr-xbin/reproducible_housekeeping.sh55
1 files changed, 55 insertions, 0 deletions
diff --git a/bin/reproducible_housekeeping.sh b/bin/reproducible_housekeeping.sh
new file mode 100755
index 00000000..717e0a23
--- /dev/null
+++ b/bin/reproducible_housekeeping.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+# Copyright 2014 Holger Levsen <holger@layer-acht.org>
+# released under the GPLv=2
+
+. /srv/jenkins/bin/common-functions.sh
+common_init "$@"
+
+# common code defining db access
+. /srv/jenkins/bin/reproducible_common.sh
+
+# common
+set +x
+REP_RESULTS=/srv/reproducible-results
+
+# prepare backup
+mkdir -p $REP_RESULTS/backup
+cd $REP_RESULTS/backup
+
+# keep 30 days and the 1st of the month
+DAY=(date -d "30 day ago" '+%d')
+DATE=$(date -d "30 day ago" '+%Y-%m-%d')
+if [ "$DAY" != "01" ] && [ -f reproducible_$DATE.db.xz ] ; then
+ rm -f reproducible_$DATE.db.xz
+fi
+
+# actually do the backup
+DATE=$(date '+%Y-%m-%d')
+if [ ! -f reproducible_$DATE.db.xz ] ; then
+ cp $PACKAGES_DB .
+ DATE=$(date '+%Y-%m-%d')
+ mv reproducible.db reproducible_$DATE.db
+ xz reproducible_$DATE.db
+fi
+
+# find and warn about old temp directories
+OLDSTUFF=$(find $REP_RESULTS -type d -name "tmp.*" -mtime +7 -exec ls -lad {} \;)
+if [ ! -z "$OLDSTUFF" ] ; then
+ echo
+ echo "Warnung: old temp directories found in $REP_RESULTS"
+ echo "$OLDSTUFF"
+ echo "Please cleanup manually."
+ echo
+fi
+
+# find and warn about pbuild leftovers
+OLDSTUFF=$(find /var/cache/pbuilder/result/ -mtime +7 -exec ls -lad {} \;)
+if [ ! -z "$OLDSTUFF" ] ; then
+ echo
+ echo "Warnung: old temp directories found in /var/cache/pbuilder/result/"
+ echo "$OLDSTUFF"
+ echo "Please cleanup manually."
+ echo
+fi
+