Redirecting Users to New Server

I am new to shell scripting. I urgently need a script on a backup server that will ping the main server to check if the server is up. If the main server is down- the script should transfer the IP of the main server to the backup server. Once the main server is up again the backup server will release the IP so that traffic will go back to the main server. The script should run as a background daemon.

and reboot the backup server just after?...
What about your hostnames and DNS?
You are looking to do some HA and there are softwares for that, making a poor man's cluster why not, but you have to think seriously how its done

Yes. I am already using Crontab and SCP to automate the back up. I want to use a simple script to automate the failover. I dont want to use any apps.

do you use any user control panel like directadmin or cpanel ?

The point is you cant automate such a system:
It will necessarily mean that at main server not responding, you would have to run a script that changes network configuration files of backup server and after reboot the server, then other way round you cannot let the main server boot while the other is running since it has the server's name and IP...
You could bypass some issues by configuring a second lan interface with another IP and "server name" known also to the DNS where configured correctly, all users land on prod server and backup server has the same but not active ( ifconfig down...)

That said maybe if you gave us more information on your environment we could suggest wiser solutions... all we know so far is 2 servers... (connected to a disk bay? seen bothe sides? OS? etc...)
Update---
And what application you are mentionning for I you may have more obvious solutions ( e.g. if its Web stuff ...) my concern was more about heavy stuff like applicaion running oracle with oracle RDBMS etc

No something simple. The backup server always on no need to reboot. 2 fedora boxes. The backup is an email backup server exactly like d main server. The script should just change IP address on d fly. The main server has a public and local IP. Both servers are connected via local interface. The backup server also have a public ip. The public ip of the backup is configured with a higher priority on d mx records. So external users can access the backup if the main server is down. But for local users pointing to the main server ip there is an issue.
The script running on the backup server should ping d main server public ip and configure the local ip of d backup server to take up d local ip of the main server and release the ip when the main server comes back online when the main server public ip become available.

---------- Post updated 09-21-13 at 12:54 AM ---------- Previous update was 09-20-13 at 11:22 PM ----------

16.	# add ip / hostname separated by white space 
17.	HOSTS="PublicIP"
18.	 
19.	# no ping request
20.	COUNT=1
21.	 
22.	# email report when 
23.	SUBJECT="Ping failed"
24.	EMAILID="me@mydomain.com"
25.	for myHost in $HOSTS
26.	do
27.	  count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
28.	  if [ $count -eq 0 ]; 
29.	
30.	  then
31.	    # 100% failed 
32.	    echo "Host : $myHost is down (ping failed) at $(date)" | mail -s "$SUBJECT" $EMAILID
33.	    /sbin/ip addr add 155.128.89.55/24 dev eth1
34.	 
35.	  else
36.	    Echo �Host is up and running�
37.	    /sbin/ip addr del 155.128.89.55/24 dev eth1
38.	  fi
39.	Done

will something like this work? I put this together from many sources.

In most cases 'something simple' will not work at crunch time. I strongly recomment that you look at the Linux HA project. See http://www.linux-ha.org/