Précédent   Forum des professionnels en informatique > Systèmes > Linux > Système
Système Vos questions autour de l'administration système
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 19/03/2007, 11h02   #1
Invité de passage
 
Inscription : janvier 2007
Messages : 11
Détails du profil
Informations forums :
Inscription : janvier 2007
Messages : 11
Points : 4
Points : 4
Par défaut Problème d'execution d'une tache cron

Bonjour à tous

J'ai trouvé un script qui permet de fair une sauvegarder de la base de données. Je peux le lancer via ssh sans problème.

Je voudrais le mettre en cron ( genre tous les 2 jours à 4h du matin) mais apparemment il ne passe pas.
Quand je le lance en ssh , il me demande de confirmer une option : ( Daily - Hourly )
en ssh je met l'option que je peux. Mais en tache cron , le script ne se lance car il demander de conformer l'option.

Voici le script :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
 
#
# Created 2005-06-24 by Matthew Montgomery - mmontgom@rackspace.com 
# 
# Change: 2006-06-01 by Matthew Montgomery
#  Add support for ibbbackup for InnoDB tables
#  Add support for MySQL 4.1 and 5.0
#
 
DATE=`date -I`
DATADIR="/var/lib/mysql"
BASE_DIR="/home/backup"
BACKUP_DIR="$BASE_DIR/current"
INTERVAL="$1"
RETENTION=14 # days
HOST=`hostname -s`
MYVERSION=`mysql -Bse "SELECT substring_index(version(),'.',2)"`
###  Uncomment this line to specify the path to and enable ibbackup for hotcopy of InnoDB tables.
# IBBACKUP="/usr/local/bin/ibbackup"
 
if [ "$MYVERSION" = '4.1' ] || [ "$MYVERSION" = '5.0' ] ; then
	PURGELOGS='mysql -e "PURGE MASTER LOGS BEFORE DATE_SUB( NOW(), INTERVAL 1 HOUR )"'
elif [ $MYVERSION = '3.23' -o "$MYVERSION" = '4.0' ]; then
	PURGELOGS='mysql -e "RESET MASTER"'
else
echo "UNSUPPORTED MYSQL VERSION"
exit 1
fi
 
if [ ! $1 ];
then
	read -p "Backup Interval? (Hourly|Daily) : " INTERVAL
fi
 
case $INTERVAL in
	hourly | HOURLY | Hourly | 1 )
	echo "Performing HOURLY level backup -- `date`"
	mysql -e "FLUSH LOGS"
	if [ -d $BASE_DIR/$DATE ] && [ "$MYVERSION" = '4.1' -o "$MYVERSION" = '5.0' ] ; then
		rsync -aub $DATADIR/$HOST-bin.?????? $BASE_DIR/$DATE
	elif [ -d $BASE_DIR/$DATE ] && [ "$MYVERSION" = '3.23' -o "$MYVERSION" = '4.0' ] ; then
		rsync -aub $DATADIR/$HOST-bin.??? $BASE_DIR/$DATE
	else 
		echo "No destination dir! please run daily backup first." 1>&2
		exit 1
	fi
	sleep 1
	find $BASE_DIR -size 98c -exec rm -rf '{}' \;
	exit 0
	;;
	daily | DAILY | Daily | 2 )
	echo "Performing DAILY level backup -- `date`"
	if [ ! -d $BACKUP_DIR ];
	then
		echo Creating $BACKUP_DIR
		mkdir -p $BACKUP_DIR
	fi
 
	if [ ! -z "$IBBACKUP" ] ; then
		$IBBACKUP /etc/my.cnf /etc/my.cnf.ibbackup 2>&1
		$IBBACKUP --apply-log /etc/my.cnf.ibbackup 2>&1
		rm $BACKUP_DIR/ibbackup_logfile
	fi
	mysqlhotcopy --regexp=.* $BACKUP_DIR
	chown -R mysql: $BACKUP_DIR/
	mv $BACKUP_DIR $BASE_DIR/$DATE
	eval $PURGELOGS
	find $BASE_DIR -ctime +$RETENTION -exec rm -rf '{}' \;
	exit 0
	;;
	* )
	echo "Invalid Selection" 1>&2
	exit 1
esac

J'ai donc une erreur "Invalid Selection"


Merci
Jarod23 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/03/2007, 15h20   #2
Membre éclairé
 
Avatar de herzleid
 
Inscription : juin 2002
Messages : 376
Détails du profil
Informations personnelles :
Âge : 33

Informations forums :
Inscription : juin 2002
Messages : 376
Points : 388
Points : 388
Bonjour,

tu peux toujours forcer la valeur dans ton script. Et donc rempacer le code :

Code :
1
2
3
4
if [ ! $1 ];
then
	read -p "Backup Interval? (Hourly|Daily) : " INTERVAL
fi
Par :

Ou la valeur que tu désires.
__________________
www.kywyxy.net
herzleid est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/03/2007, 10h19   #3
Invité de passage
 
Inscription : janvier 2007
Messages : 11
Détails du profil
Informations forums :
Inscription : janvier 2007
Messages : 11
Points : 4
Points : 4
Merci , j'ai testé et ça marche
Jarod23 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 09h40.


 
 
 
 
Partenaires

Hébergement Web