Jump to content

Recommended Posts

Posted

I have written a short script to back up a proxy server running ubuntu 10.10 using smbfs share and rsync but when the rsync is complet it fails to unmount the directory i have also tryed forcing the umount and this also fails.

umount -fv /mount_location

umount: Device or resource busy

 

[script]

mount -t smbfs -o username=*,password=* //Remote_Mount /Local_Mount_Point

 

/Local_Mount_Point/rsync (this runs the actual rsync comand as i was having errors on rsync if the mount failed and with this option it cant run if the mount fails)

 

[rsync script]

rsync -auv --exclude /remotemnt --exclude /squidcache /* /Local_Mount_Point

 

cd /var

 

umount -fv /Local_Mount_Point

 

any ideas ?

Posted

thanks for the reply I have run

lsof | grep rsync

and nothing is displayed however when the below is run

lsof | grep /Local_Mount_Point

shows the local user that mounted the drive is in the folder even when the script tells it to go back to the home directory after running rsync

Posted

Sorry, I should have read your initial post more clearly. You're trying to unmount /Local_Mount_Point using the rsync script sitting inside it - that'll never work.

 

You can't unmount something that's being accessed. You especially can't if the thing you're trying to umount it with is the thing sitting inside it. Even though you change directory to /var within the script, the script is still running from /Local_Mount_Point.

 

Run your script from the user's homedir and pick another way of checking for a failed mount, say checking /proc/mounts for your particular share.

 if ! grep -q /Remote_Mount /proc/mounts ; then
   if ! mount /Remote_Mount ; then
     echo "failed"
     exit 1
   fi
 fi
 echo "succeeded."
 # do rsync stuff here

 

(Example nicked from ServerFault)

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...