source: cpc/trunk/project/bin/autodump @ 2686

Last change on this file since 2686 was 1786, checked in by goya, 10 years ago

oubli commit tangui sur archive solr

  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/bin/bash
2if [ -z "$1" ] ; then
3source bin/db.inc
4else
5source $1
6fi
7
8mysqldump $MYSQLID $DBNAME -q --single-transaction --add-drop-table -R -t --disable-keys --complete-insert | gzip > $DUMPDIR/$DBNAME.$(date +%y%m%d).sql.gz
9if test -n "$SOLR_DATA_PATH" ; then
10        tar zcf $DUMPDIR/$DBNAME.$(date +%y%m%d).solr.tar.gz $SOLR_DATA_PATH
11fi
12
13# On archive tous les 1er du mois et tous les dimanches
14if [[ $(date +%-w) -eq 0 || $(date +%-d) -eq 1 ]]; then
15  cp $DUMPDIR/$DBNAME.$(date +%y%m%d).s*.gz $DUMPDIR/archives/
16fi
17
18# On efface tous les mois les archives hebdomadaires vieilles de plus d'un mois mais on garde l'archive mensuelle
19if [[ $(date +%-d) -eq 1 ]]; then
20  if [[ $(date +%-m) -le 2 ]]; then
21    year0=`expr $(date +%y) - 1`
22    month0=`expr $(date +%m) + 10`
23  else
24    year0=`expr $(date +%y) + 0`
25    month0=`expr $(date +%m) - 2`
26  fi
27  ym=`printf "%02d%02d" $year0 $month0`
28  rm -f `ls $DUMPDIR/archives/$DBNAME.${ym}*.s*.gz | grep -v .${ym}01.sql.gz`
29fi
30
31# On efface les dumps vieux de plus d'une semaine
32if [[ $(date +%-d) -le 7 ]]; then
33  day0=`expr $(date +%d) + 21`
34else
35  day0=`expr $(date +%d) - 7`
36fi
37rm -f $DUMPDIR/$DBNAME.*`printf "%02d" $day0`.s*.gz
38if [[ $(date +%-d) -eq 8 ]]; then
39  rm -f $DUMPDIR/$DBNAME.*29.s*.gz
40  rm -f $DUMPDIR/$DBNAME.*30.s*.gz
41  rm -f $DUMPDIR/$DBNAME.*31.s*.gz
42fi
43
Note: See TracBrowser for help on using the repository browser.