[ubuntu-uk] commands to navigate a windows network for a script
Rob Beard
rob at esdelle.co.uk
Tue Apr 14 16:52:17 BST 2009
doug livesey wrote:
> Hi -- I have set up a database server at work that I currently run
> backups on myself, but wish to put this into a cron job.
> One of the things I would like to do is to have that backup take
> place, then to have it copied over to our work's windows network,
> where it can be caught in our nightly backup to tape.
> Could anyone offer me some pointers as to how I should write this
> script, particularly with reference to how I get on to & navigate the
> windows network?
> Thanks,
> Doug.
Presumably you'd want your backup script to copy the data to the Windows
machine with the tape drive on it?
What you'll need to do is mount a share on the Window server. If you
install the smbfs package you'll be able to use either smbmount or mount
with the type cifs or smbfs (although IIRC smbfs is being replaced by cifs).
I normally do this when backing up machines using Partimage on the
System Rescue CD.
I'd enter a command such as...
sudo mount -t cifs -o username=myusername,password=mypassword
//server/share /mnt/mountpoint
Where myusername is the username of the user who is connecting to the
share, mypassword is the users password, you can also store the password
in a password file. If it was me I'd create a basic user with limited
access to just the one share and nothing else, that way if the password
was compromised then it should in theory limit the access that that
particular user can access. I believe you can also specify a domain too
using domain=mydomain.
//server/share is the address of the server and the share name, this can
also be an ip address for instance //192.168.0.1/myshare
Note the slashes are forward slashes rather than backslashes but still
are double slashes (//).
Finally /mnt/mountpoint points to a mount point on the Linux box running
the script.
To unmount the share just use sudo umount /mnt/mountpoint
If you're always going to use the same share you could also put the
details in fstab which should then resolve the need to mount the share
as root (using sudo).
You can find plenty of information too in the smbmount man page (man
smbmount) after you have installed the smbfs package.
Basically once the share is mounted on the Linux filesystem then it
should work pretty much like any other file or directory although
anything you store in there will be owned by the user you used to mount
the share.
Hope this helps.
Rob
More information about the ubuntu-uk
mailing list