Autor Tópico: Backup não funciona pelo cron  (Lida 3235 vezes)

Offline brottor

  • Usuário Ubuntu
  • *
  • Mensagens: 156
    • Ver perfil
Backup não funciona pelo cron
« Online: 01 de Fevereiro de 2010, 09:06 »
Bom dia senhores,

Eu rodo um script de backup todo dia as 20h. O script rodando na mão funciona, porém pelo cron ele gera um erro, e so gera um arquivo de 2.0mb sendo q o certo é um arquivo de 900mb

o ubuntu q faz backup é o 8.04 server.

o script é esse:

Código: [Selecionar]
#!/bin/bash
POSNOME="mail.zimbra"
TMP_DIR="/home/serverbkp"
BKP_DIR="/opt/zimbra"
BKP_DIR_EXCLUDE=" "

# Binario de backup e diretorio temporario
TAR=/bin/tar
TAR_OPTS="-czvP"
SQLDUMP="/usr/local/bin/mysqldump"
SQLDUMPOPTS="-h localhost -u certificacoes -pAker2009 --all-database"
TMP_DIR="/home/serverbkp"
HOSTNAME=`hostname`
DATAHJ=`date +%y%m%d`
ARQUIVO=`echo -n "$HOSTNAME-$POSNOME-$DATAHJ.tgz"`

echo "Iniciando Backup Diario: $DATAHJ"

# Para o Zimbra
/etc/init.d/zimbra stop
sleep 60
pkill -9 -u zimbra

cd /root
chmod 700 $TMP_DIR

echo "DUMP do banco e bkp de aplicacoes"
$TAR $BKP_DIR_EXCLUDE $TAR_OPTS -f $TMP_DIR/$ARQUIVO $BKP_DIR # >> /root/teste.txt 2> &1
cp *.sh $TMP_DIR/.
chown serverbkp /home/serverbkp/*

# Start Zimbra Services
/etc/init.d/zimbra start

echo "Acabou!"


alguem ja passou por esse problema com o cron?
Linux Professional Institute Certificated Level 2.
LPI000220827

Offline jeflui

  • Usuário Ubuntu
  • *
  • Mensagens: 745
    • Ver perfil
Re: Backup não funciona pelo cron
« Resposta #1 Online: 01 de Fevereiro de 2010, 10:08 »
Coloca sua conf do crontab aqui.

Offline brottor

  • Usuário Ubuntu
  • *
  • Mensagens: 156
    • Ver perfil
Re: Backup não funciona pelo cron
« Resposta #2 Online: 01 de Fevereiro de 2010, 10:19 »
Código: [Selecionar]
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
17 * * * * root    cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

30 12 * * 1-5 root /root/bkp-mail.aker.com.br.sh

##0 21,23,02,05 * * 5,6,1 root /root/print-backup.sh

Linux Professional Institute Certificated Level 2.
LPI000220827

Offline jeflui

  • Usuário Ubuntu
  • *
  • Mensagens: 745
    • Ver perfil
Re: Backup não funciona pelo cron
« Resposta #3 Online: 01 de Fevereiro de 2010, 11:09 »
O cron está usando como shell sh e seu script bash, pode ser isso.

Offline brottor

  • Usuário Ubuntu
  • *
  • Mensagens: 156
    • Ver perfil
Re: Backup não funciona pelo cron
« Resposta #4 Online: 01 de Fevereiro de 2010, 18:28 »
troquei o shell do script. tbm não foi.

tava achando q podia ser variavel de ambiente. mas o script ta certo.
Linux Professional Institute Certificated Level 2.
LPI000220827

Offline brottor

  • Usuário Ubuntu
  • *
  • Mensagens: 156
    • Ver perfil
Re: Backup não funciona pelo cron
« Resposta #5 Online: 02 de Fevereiro de 2010, 10:04 »
quando fui rodar na mão apareceu isso:


/bin/tar: Error exit delayed from previous errors
Linux Professional Institute Certificated Level 2.
LPI000220827