Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have a Windows server that I want to backup all the Shares through a script automatically to my MacBook Pro running OSX 10.6.8. There is no common folder all the shares are in, they are just mounted as \\SERVER\Share_Name. I want to be able to have a script that cycles through all the shares on a server (even if the folder names are unknown at the time the script is created), and create a backup on a local folder on my Mac. Or, if there's an easier way than a script, or drag-and-drop (that doesn't seem to always copy all the files)

share|improve this question

1 Answer 1

up vote 1 down vote accepted

There's no root in Samba protocol. To list shares on your server you can use smbutil(1):

$ smbutil view //Administrator@10.211.55.8/ | awk '$2=="Disk"{print $1}'
ADMIN$    
C$        

and then use output with mount_smbfs(8):

smbutil view //Administrator@10.211.55.8/ | awk '$2=="Disk"{print $1}' | while read sharename; do 
  mkdir ${BASE}/${sharename}; 
  mount_smbfs //Administrator@10.211.55.8/${sharename} ${BASE}/${sharename};
done

Please, read man pages to check other options I haven't used here.

The best utility to make backup I know is rsync(1). You can found it from MacPorts. It'll be interest if you know better.

share|improve this answer
    
+1 for the Samba Protocol thing. I did some more reading on it last night, and I saw that part. I like the idea of using a script, but need to still learn more about RSYNC. I will try your script, then mark as the answer if it works. I assume just above the done line is where I put my cp command? –  Canadian Luke Nov 16 '11 at 18:49
    
I know that there's some problems with UTF-8 support. I use Mac OS X Lion 10.7.2 and have problems with mount non-english shares when use mount_smbfs or Finder. I think it's general Mac OS X problem. And don't forget to make sudo(1) before running this script –  Eir Nym Nov 16 '11 at 19:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.