8.1 mksnap_ffs: Cannot create snapshot //.snap/dump_snapshot: ?

Hello fellas,

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
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.
 
killasmurf86 said:
perhaps it's extra / then script is running automatically

Aahh, I'm sorry, I don't think I follow .....

Also note, that UFS snapshots have Max limit of 20 snapshots
So, you make 20 snapshots and that's it ?
No, it cannot be .... maybe there is something wrong this morning with me because I don't think I follow this one either.

Please be so kind and elaborate :)
 
ufs is limited to 20 snapshots at any time per UFS filesystem....
If you want new snapshots, you have to delete some old ones

if you want more than 20 snapshots, use zfs
 
killasmurf86 said:
Code:
mksnap_ffs: Cannot create snapshot [red]/[/red]/.snap/dump_snapshot: ?(: Device busy

ahaa .. I see it.

thx, I'll look into that .... but still, it's weird it only fails when ran from crontab
 
Crontab uses /bin/sh, you may not. The script doesn't have a #!shell defined at the beginning, so maybe there's something 'shell-specific' in your script that causes it to fail when run from cron? Just a guess. Maybe switch from backticks to more modern syntax as well.

Code:
date=`/bin/date`
date=$(/bin/date)
 
UPDATE:

I commented out the following line:
Code:
# Delete the temp snapshot
$rm -f /.snap/dump_snapshot
and set the crontab to run 1 min after the modification. basically, it worked.

I've set the crontab job back to it's original hour and I will see tomorrow.

@killasmurf86: atm, I have only 5 snapshot's in the "target_dir". This shouldn't be a problem if you say, 20 is the limit.
I also tried ZFS about 3 weeks ago but I couldn't get a higher than 20MB/sec write speed, so off it went and in came ufs (again).
 
So, last night the script ran without any error.

Another change I did was modify the minutes in crontab from "*" to "1". This way, the script is started only one time, whereas with "*" the script was started every other minute and I'm guessing that was the cause for the "resource unavailable" error msg.
 
Back
Top