Friday, 23 February 2007

Mounting a network drive and dabbling in cron jobs

Now before you all think I have gone crazy and started a sideline in email scams I must explain some background before things will become clear.

Our new all singing and dancing application we are building in Manchester is starting to become useful and inevitably when something becomes useful people start actually using it to do important work. Also when people start using software they trust their friendly IT manager to look after all their useful information in a responsible manner so that if anything bad happened their precious information will be preserved. Imagine if you will a collection of harvest mice with a big stash of blackberries, if the stash of berries is squished the IT manager has an opportunity to become a hero by unsquishing them or alternatively slightly fired :o)





(The operations Director was very angry when she found out all the data was lost)


So the solution for guarding our 'blackberries' is to duplicate them and put them in several places at the same time, we have a clever piece of software in head office which does this - when it can be bothered (thank you to the creators of retrospect). However our new system is being created on a Linux server and as such has no access to our main backup software so we have had to create our own. Its pretty simple really, every night copy our 'pile of blackberries' from this place to this other place, as I have bored you already with the story of replicating our database we are simply concerned here with files. The thing is that there would be no point in copying our files from one part of the Linux server to another so it needs to be sent to head office, this means going from Linux to windows and this is where the fun is.

And so to a brief instruction on mounting a windows network share:
1. Stretch - its important.
2. Create a new windows account on your domain.
3. Create a folder on your windows server and allow access to it for your new user
4. Try connecting to it using the following command:

mount.cifs //servername.domain/share /mnt/ -o user=user,password=password,domain=domain

Don't try smb, mount, mount.smb or any of that because it doesn't work, I have no idea why - its probably very simple but 2 hours of banging my head against it could not get it going!

If the preceding command works edit your /etc/fstab file and simply copy and paste the command into it. That way every time you restart your Linux machine it will automatically make your windows share available to you in /mnt/ magic!

So next to the cron job:
For those of you who do not know, cron is a simple program which runs another program at a certain time on a certain day so you don't have to remember to. A cron job is a preconfigured task which cron will perform at a specified time and date, told you I could explain.

In our scenario we have a very simple command to be run cp -r "/home/store" "/mnt/" so the first step is to simply run it at the command line and see if it works. If it does you copy and paste the line into the /etc/crontab file with a preceding '0 1 * * *' which it turns out translates 'to please run this every night at 1am' simple really.

I hope you find this ramble as useful as I would have done if I had found it 2 hours ago :o)

3 comments:

Anonymous said...

Hey thank you for the wonderful article it had been genuinely useful , I hope you will just publish additional about this ! This topic rocks

Anonymous said...

This is a good blog. Keep up all the work. I too love blogging and expressing my opinions. Thanks

Anonymous said...

I am glad to be one of several visitants on this outstanding internet site (:, thankyou for putting up.

A view from the rack is the personal blog of an IT manager who works for a pub company - hence beer