RSync Operation Timeout

I set up an rsync with cron to backup files on a freebsd 8.0

using below code:
Code:
SRCDIR="/home/users"
BACKUPDIR="/mnt/BACKUP"
LOGERRFILE="/<some_path>/file_users_logERR.txt"
LOGOKFILE="/<some_path>/file_users_logOK.txt"

if [ ! -d "$BACKUPLOC" ]; then
        mount_smbfs -I <ip_address> -L en_US.ISO8859-1 -W Workgroup -N //guest@<ip_address>/Volume_1/ /mnt/BACKUP
fi

echo "" > "$LOGERRFILE"


/usr/local/bin/rsync -avzh --progress --iconv=UTF-8,ISO8859-1  "$SRCDIR"  "$BACKUPDIR"  2> "$LOGERRFILE" > "$LOGOKFILE"

if [ -s "$LOGERRFILE" ]; then

   //send email
   exit 1
fi

But there is a problem when I scheduled it using Cron Jobs in the Freebsd
Code:
rsync: mkstemp ... failed: Operation timed out (60)
rsync: recv_generator: .... class": Operation timed out (60

The /mnt/BACKUP is a mounted Network Storage(NAS)

Please advise
 
mount -t smbfs is not working, but /usr/sbin/mount_smbfs is working fine.

The whole script is running smoothly if I run in manually
 
Try this on your first two lines of your script:
Code:
SET IFS='
'
and see if it runs. If not, explain how you run it via CRON.
 
I saved the script on a file /home/script/backup.sh.

Code:
#!/bin/bash

SRCDIR="/home/users"
BACKUPDIR="/mnt/BACKUP"
LOGERRFILE="/<some_path>/file_users_logERR.txt"
LOGOKFILE="/<some_path>/file_users_logOK.txt"

if [ ! -d "$BACKUPLOC" ]; then
        mount_smbfs -I <ip_address> -L en_US.ISO8859-1 -W Workgroup -N //guest@<ip_address>/Volume_1/ /mnt/BACKUP
fi

echo "" > "$LOGERRFILE"


/usr/local/bin/rsync -avzh --progress --iconv=UTF-8,ISO8859-1  "$SRCDIR"  "$BACKUPDIR"  2> "$LOGERRFILE" > "$LOGOKFILE"

if [ -s "$LOGERRFILE" ]; then

   //send email
   exit 1
fi

Then I configure using crontab -e

Code:
0 6 * * * /home/script/backup.sh
 
IFS is the Internal Field Separator. For more info you can read this. The thing is that it is not uncommon for shell programs to behave "unexpected" and the strange behaviours vanish once the IFS is set properly. So, my suggestion is to set it as the new line character. Have you tried it? Did it work?

Secondly: as what user are you running the cron script? root I suppose?
 
I don't see where IFS would be a problem here.

1. As said above, it is important to test that the mount succeeds. It could fail for any number of reasons, and the script will fail. Possibly just like it does.
2. Don't use bash.
3. BACKUPLOC is is not defined. BACKUPDIR is used in the rsync command.
 
1. The mount is working fine

2. Please advise what should I use, sh:
Code:
#!/bin/sh

3.Sorry for the wrong code
Code:
if [ ! -d "$BACKUPDIR" ]; then
 
aceman said:
1. The mount is working fine

Disconnect a network cable, or turn off the NAS, change permissions, or use a different environment. These will all cause the script to fail. That's why it should test for success.

The test to see if BACKUPDIR is a directory is not useful. To be a mountpoint, it is already a directory. A better test would be to see if BACKUPDIR contains a known file that is in the mounted directory but not in the empty mountpoint.

2. Please advise what should I use, sh:
Code:
#!/bin/sh

Yes.
 
Back
Top