1

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)

2

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.

2
  • +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? 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .