tyr
(usa Slackware)
Enviado em 25/03/2015 - 10:59h
Bom dia pessoal.
fiz um script de backup automático fico tudo certo tudo funciona quando executo manualmente, porem quando coloco no crontab ele gera um log falando que o comando sshpass não existe segue script, log e crontab
########Script######
#!/bin/bash
#
#
#
#
echo -e "\033[0;32m###########################\033[0m"
sleep 0.30
echo -e "\033[0;32m# SCRIPT DE BACKUP #\033[0m"
sleep 0.30
echo -e "\033[0;32m# DESENVOLVIDO POR RAFAEL #\033[0m"
sleep 0.30
echo -e "\033[0;32m# VERS▒?O 1.0 #\033[0m"
sleep 0.30
echo -e "\033[0;32m###########################\033[0m"
sleep 2
#Variaveis do Script
#Mover backup antigo para a pasta oldbkp
MOVE="mv *.zip"
#User e senha para envio de bkp para maquina remota
SSHPASS="sshpass -p"
PASS1="#senha#"
SCP="scp"
ARQ="*.zip"
USER="admin@ip-server:"
#Datas para log e bkp gerado
DATA=`date +%H-%Mx%d.%m.%Y`
DATAA=`date +%H-%Mx%d.%m.%Y`
#Log do backup
LOG="/var/log/samba/logbkpsamba/backup-$DATAA.log"
#Diretorios que são Feitos os bkps
D1="/ura/ti/rafael/"
D2="/ura/ti/aldo/"D3="/ura/atende/everton/"
D4="/ura/atende/tais/"
D5="/ura/atende/renata/"
D6="/ura/geren/rhaiane/"
D7="/ura/geren/drausio/"
D8="/ura/laudos/wellington"
D9="/ura/laudos/eberton/"
D10="/ura/supri/tamara/"
D11="/ura/tria/"
#Barra de loading
BAR1="/backup/bar1.sh"
BAR2="/backup/bar2.sh"
###Fim das Variaveis do Script###
echo -e "\033[0;36mCarregando Arquivos de Backup\033[0m"
$BAR1
#Variavel de Origendo do bkp
DIR_ORIG="$D1 $D2 $D3 $D4 $D5 $D6 $D7 $D8 $D9 $D10 $D11"
#Diretorio de Destino do bkp
DIR_DEST="/backup/"
sleep 2
echo -e "\033[0;36mFazendo o Backup\033[0m"
zip -r $DATA.zip $DIR_ORIG &> $LOG
sleep 2
echo -e "\033[0;36mAcessando o Diretorio\033[0m"
sleep 2
cd $DIR_DEST
sleep 2
echo -e "\033[0;36mEnviando o Backup\033[0m"
$SSHPASS $PASS1 $SCP $ARQ $USER
$BAR2
sleep 2
echo -e "\033[0;36mMovendo Backup\033[0m"
sleep 2
$MOVE /oldbkp/
sleep 2
echo -e "\033[0;36mExit\033[0m"
######LOG#####
^[[0;32m###########################^[[0m
^[[0;32m# SCRIPT DE BACKUP #^[[0m
^[[0;32m# DESENVOLVIDO POR RAFAEL #^[[0m
^[[0;32m# VERS▒?O 1.0 #^[[0m
^[[0;32m###########################^[[0m
^[[0;36mCarregando Arquivos de Backup^[[0m
^[[0;36mFazendo o Backup^[[0m
^[[0;36mAcessando o Diretorio^[[0m
^[[0;36mEnviando o Backup^[[0m
./t.sh: line 85: sshpass: command not found
^[[0;36mMovendo Backup^[[0m
^[[0;36mExit^[[0m
#####CRONTAB######
# /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/bash
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
0 12 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
15 12 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
30 12 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
48 10 * * 3 (cd /backup/ && ./t.sh >>Script.log 2>&1)