From dfbd71c34b82f956133e362478d6228121e6d19e Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Tue, 4 Aug 2015 15:13:14 +0200 Subject: reproducible: db maintenance only on jenkins --- bin/reproducible_maintenance.sh | 42 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/bin/reproducible_maintenance.sh b/bin/reproducible_maintenance.sh index 49ef8ece..7b434a90 100755 --- a/bin/reproducible_maintenance.sh +++ b/bin/reproducible_maintenance.sh @@ -12,29 +12,31 @@ common_init "$@" DIRTY=false -# prepare backup -REP_RESULTS=/srv/reproducible-results -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 +if [ "$HOSTNAME" = "jenkins" ] ; then + # prepare backup + REP_RESULTS=/srv/reproducible-results + 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 -v $PACKAGES_DB . + # actually do the backup DATE=$(date '+%Y-%m-%d') - mv -v reproducible.db reproducible_$DATE.db - xz reproducible_$DATE.db -fi + if [ ! -f reproducible_$DATE.db.xz ] ; then + cp -v $PACKAGES_DB . + DATE=$(date '+%Y-%m-%d') + mv -v reproducible.db reproducible_$DATE.db + xz reproducible_$DATE.db + fi -# provide copy for external backups -cp -v $PACKAGES_DB $BASE/ + # provide copy for external backups + cp -v $PACKAGES_DB $BASE/ +fi # delete old temp directories OLDSTUFF=$(find $REP_RESULTS -maxdepth 1 -type d -name "tmp.*" -mtime +2 -exec ls -lad {} \;) -- cgit v1.2.3-70-g09d2