Cron dumps with files of the same name

jcerdan

New Member
Nov 21, 2013
6
0
1
Hi,

I'm creating a cron job to make dumps of OpenVZ CT's. This cron must always export the same name: ex: vzdump-openvz-100.tar.lzo

Currently, this cron works on the terminal when manually launched, but when launched by cron it does not work. I believe that the problem is on the stdout param used on vzdump, but I don't know how to solve this. Here's the script:

Code:
#backup Containers openvz
rm /backup/dump/vzdump-openvz-100.tar.lzo
vzdump --maxfiles 1 --compress lzo --mode snapshot --storage backup --mailto xxxxx@xxxx.xxx 100 -stdout > /backup/dump/vzdump-openvz-100.tar.lzo

Has someone an idea on how to solve this?

Best,
 
Hi Marco,

I think that the problem is in calling the script from the cron and redirecting output to a file.
Th cron is called like that:
0 4 * * * /root/daily-backup.sh > /root/cron.log 2>&1

Could the redirection to a file be the cause?

There's no errors on system log
 
I have now changed my script to an older one I done. Here's the script that has to run under cron. It checks if the dump is correctly done and if not, retires un til 10 attemptys are reached. This one does the same, cron runs, but no dump is created... ????

Code:
vmid=100
host=xxxxxxx
storage=local
maxfiles=15
backupdone=false
backuptries=10

function backupvm () {

  /usr/bin/pvesh create /nodes/$host/vzdump -vmid "$vmid" -mailto xxxxx@xxxx.xxxx -storage "$storage" -mode suspend -compress lzo -maxfiles "$maxfiles" -remove true > cron.log

  task=`tail -1 cron.log`
  #echo $task

  /usr/bin/pvesh get /nodes/$host/tasks/$task/status > task.log
}

echo "starting VM backup..." >> backup-$DATE.log

while [ $backupdone != true ] && [ $backuptries -gt 0 ]
do
  backupvm
  echo "backup try $backuptries" >> backup-$DATE.log
  backuptries=`expr $backuptries - 1`
  while read line
  do
    #echo $line
    if echo $line | grep -q "exitstatus"; then
      if echo $line | grep -q "OK"; then
        backupdone=true
        echo "backup done... at try $backuptries" >> backup-$DATE.log
      fi
    fi
  done < task.log
done

This script executed manually works fine. ??? I can't find what's wrong. Has someone an idea?

Best,