Browse Source

chef_orchestre : backup zip par mail, tar.gz gardée, .err.tgz si nok, .ok.tgz sinon

Citnop 3 years ago
parent
commit
498f23a363
1 changed files with 23 additions and 3 deletions
  1. 23 3
      chef/chef_d_orchestre.sh

+ 23 - 3
chef/chef_d_orchestre.sh

@@ -378,10 +378,27 @@ ERR=$(($ERR + $res))
378 378
 #-------------------------------------------------------------------------------
379 379
 
380 380
 
381
-# \n --> \r\n
381
+# \n --> \r\n et backup fichier
382 382
 res=0
383 383
 /home/administrateur/prod/postparser/n2rn.out < "/var/log/yaplog/yaplog.${AJD}.${NRUNAJD}.log" > "/var/log/yaplog/yaplog.${AJD}.${NRUNAJD}.log.tmp" # tmp file for mail to windows
384 384
 res=$(($res + $?)) # success ?
385
+if [ "${ERR}" = "0" ]
386
+then
387
+	# pas erreur. archive.
388
+	tar cfvz "/var/log/yaplog/yaplog.${AJD}.${NRUNAJD}.log.ok.tar.gz" "/var/log/yaplog/yaplog.${AJD}.${NRUNAJD}.log"
389
+	res=$(($res + $?)) # success ?
390
+else
391
+	# il y a eu une ou plusieurs erreurs. archive.
392
+	tar cfvz "/var/log/yaplog/yaplog.${AJD}.${NRUNAJD}.log.err.tar.gz" "/var/log/yaplog/yaplog.${AJD}.${NRUNAJD}.log"
393
+	res=$(($res + $?)) # success ?
394
+fi
395
+if [ "$?" = "0" ]
396
+then 
397
+	mv -f "/var/log/yaplog/yaplog.${AJD}.${NRUNAJD}.log.tmp" "/var/log/yaplog/yaplog.${AJD}.${NRUNAJD}.log" # crosoft aime pas les fichiers .tmp
398
+else
399
+	serr "Pas réussi à backuper l'archive"
400
+	exit 1; # pour ne pas supprimer de fichiers de log.
401
+fi
385 402
 if [ "$res" = "0" ]
386 403
 then
387 404
         sok "n2rn ok."
@@ -392,9 +409,12 @@ ERR=$(($ERR + $res))
392 409
 #-------------------------------------------------------------------------------
393 410
 
394 411
 
395
-# send report
412
+# compress and send report
396 413
 res=0
397
-/usr/bin/sendemail -xu ${LOGIN}"@"${NDD} -xp ${MDPMAIL} -s ${SMTPSERVER}":"${SMTPPORT} -f ${LOGIN}"@"${NDD} -t ${DSTMAIL}"@"${NDD} -u ${MAILOBJ} -m ${MAILMSG} -a ${LOGFILE}".tmp" > /dev/null # send mail & shut up about it
414
+zip "/var/log/yaplog/yaplog.${AJD}.${NRUNAJD}.log.zip" "/var/log/yaplog/yaplog.${AJD}.${NRUNAJD}.log" # compress for mail
415
+res=$(($res + $?)) # success ?
416
+rm -f "/var/log/yaplog/yaplog.${AJD}.${NRUNAJD}.log" # delete log whose backup is in zip sending, and tar.gz stored.
417
+/usr/bin/sendemail -xu ${LOGIN}"@"${NDD} -xp ${MDPMAIL} -s ${SMTPSERVER}":"${SMTPPORT} -f ${LOGIN}"@"${NDD} -t ${DSTMAIL}"@"${NDD} -u ${MAILOBJ} -m ${MAILMSG} -a ${LOGFILE}".zip" > /dev/null # send mail & shut up about it
398 418
 res=$(($res + $?)) # success ?
399 419
 rm -f "/var/log/yaplog/yaplog.${AJD}.${NRUNAJD}.log.tmp" # delete temporary windows file
400 420
 if [ "$res" = "0" ]