Hello fellas,
on a 8.1-release i386 I have the following in crontab:
The last one, backup_plan.sh, is failing miserably in 80% of times.
The script looks like this:
It may not be the best script and it may not be written in the best way, but when I run it manually it works.
When crontab runs it however it fails with:
and it keeps at it for ~1h (in which time the root mailbox get's ~60-80 e-mails about this error)
At the time the backup script runs, there is pretty much no activity on the server.
It occurred to me that open files may be a problem but as far as I know that's what the "-L" dump option is for (for mounted FS's). Ow, the FS specified in the script is the "/" partition.
Can anyone give me a hint here ?
LE:
I realize that "/.snap/dump_snapshot" doesn't exist, but this is not a problem when I run the script manually. The weir thing is that even when the file was there, the crontab script was failing.
on a 8.1-release i386 I have the following in crontab:
Code:
*/10 * * * * root /root/scripts/util/connection_check
*/10 * * * * root /root/scripts/util/ftpguard.sh /var/log/messages &> /dev/null
15 3 * * * root /usr/local/bin/cvsup -g -L 2 -h `/usr/local/bin/fastest_cvsup -q -c tld` /root/cvsup/ports-supfile
[B]* 2 * * * root /root/scripts/util/backup_plan.sh[/B]
The last one, backup_plan.sh, is failing miserably in 80% of times.
The script looks like this:
Code:
################ Variables #################
fs="/dev/mirror/gm0s1a" # Set which FS's to be backed up
# full path
fs2=gm0s1a # Set to ONLY name of slice/partition itself
# do not set full path here
target_dir="/mnt/date/backups" # Target dir
filename="$fs2.`/bin/date +%a.%d.%m.%Y`" # File name format
fstab="/etc/fstab"
fstab_copy="fstab"
############### Executables ################
today=`date +%a`
date=`/bin/date`
dump="/sbin/dump"
find="/usr/bin/find"
rm="/bin/rm"
cp="/bin/cp"
swapinfo="/usr/sbin/swapinfo"
########### !!! MAINTENANCE !!! ############
# Delete all backups older than 30 days
$find $target_dir -mtime +30d -exec $rm -rf {} \;
# Move fstab to $target_dir to have a copy
# & insert swapinfo data
$cp /etc/fstab $target_dir
echo "" >> $target_dir/$fstab_copy
$swapinfo >> $target_dir/$fstab_copy
for i in $fs;
do
case $today in
Sun) $dump -0Lauf $target_dir/$filename.L0.dump $fs;;
Mon) $dump -1Lauf $target_dir/$filename.L1.dump $fs;;
Tue) $dump -2Lauf $target_dir/$filename.L2.dump $fs;;
Wed) $dump -3Lauf $target_dir/$filename.L3.dump $fs;;
Thu) $dump -4Lauf $target_dir/$filename.L4.dump $fs;;
Fri) $dump -5Lauf $target_dir/$filename.L5.dump $fs;;
Sat) $dump -6Lauf $target_dir/$filename.L6.dump $fs;;
*) echo "Unknown day of week. Exiting ...";;
esac
done
It may not be the best script and it may not be written in the best way, but when I run it manually it works.
When crontab runs it however it fails with:
Code:
mksnap_ffs: Cannot create snapshot //.snap/dump_snapshot: ?(: Device busy
dump: Cannot create //.snap/dump_snapshot: No such file or directory
At the time the backup script runs, there is pretty much no activity on the server.
It occurred to me that open files may be a problem but as far as I know that's what the "-L" dump option is for (for mounted FS's). Ow, the FS specified in the script is the "/" partition.
Can anyone give me a hint here ?
LE:
I realize that "/.snap/dump_snapshot" doesn't exist, but this is not a problem when I run the script manually. The weir thing is that even when the file was there, the crontab script was failing.