Beruflich Dokumente
Kultur Dokumente
---------------------------------------
Things to Do:-
Here are two script file coding is given you have to
copy its content to a new file with server_copy.sh
and client_copy.sh respectively..
Scripts :-
1. server_copy.sh
2. client_copy.sh
NOTE
-----
- During script execution pay special attention to the output.
- Jot down all the enteries which you enter during the script running
as undoing is not possible after any entered text
- Do not rename client_copy.sh
- Do not confuse with Client or Slave keywords both reference to the
Second machine
- This script is made to take backup hourly...
NEED
-----
The basic need for this type of backup is concerned for few machines.
Where Server will be your main Machine which has important data and
Slave(Client) machine which will required when main machine some how
stop working.
DISCLMAIR
----------
I have run these scripts on RHEL5 machines and never got stuck, but i'm
not guranteed with other Linux machines so i will not be responsible
for any damage to your machine or leak of data. So you have to run
these scripts on your own risk.
For any suggestion, queries and bugs you are always welcomed at
sachan13b.piyush@gmail.com
HOW TO START
------------
- Copy both .sh files to the main server then execute server_copy.sh
# sh server_copy.sh
or,
# ./server_copy.sh
---------------------------------
SCRIPTS
-----------------------------------
--
----------------------------------------
----------------------------------------
---------------------------------
server_copy.sh
-------------------------------------
#!/bin/bash
#Date : 14-Sep-2009
#email: sachan13b.piyush@gmail.com
#
#Sharing data in network
#
DEFPERM=755
echo -e "Note: Use absolute path\n\tEnter the path of your backup
folder : \c"
read NFS
----------------------------------------
---------------------------------
client_copy.sh
-------------------------------------
#!/bin/bash
#Automated backup - Slave machine
#Date : 14-Sep-2009
#email: sachan13b.piyush@gmail.com
#
echo -e "Note: Use absolute path\n\tType the folder name to access
backup : \c"
read CDIR
mkdir -p $CDIR
#
#Adding entry in /etc/fstab file
#
echo -e "\tType the nfs server IP : \c"
read SIP
echo -e "\tType the Server's nfs share path :\c"
read NFSHARE
echo -e "$SIP:$NFSHARE\t$CDIR\tnfs\tdefaults\t0 0" >> /etc/fstab
#
#This will start all services related to NFS
#
chkconfig netfs on
chkconfig nfslock on
chkconfig portmap on
service netfs restart
service nfslock restart
service portmap restart
#
#mount NFS folder - I guess it already mount the folder of /etc/fstab
after restarting nfs services but to sure use this command
#
#mount $CDIR
#
#Create Backup folder or specify an existing one, don't bother on error
if folder exists
#
echo -e "Note: Use absolute path\n\tEnter the folder name where backup
to be taken : \c"
read CCP
mkdir -p $CCP
#
#Setting crontab in /etc/cron.hourly/
#
echo -e "\tType a new name for your crontab file : \c"
read CRONFILE
echo $CDIR | grep /$ > /dev/null
STATUS=$?
if [ "$STATUS" -eq 0 ]; then
echo -e "cp\t-arf\t$CDIR.\t$CCP" >> `echo "/etc/cron.hourly/$CRONFILE"`
else
echo -e "cp\t-arf\t$CDIR/.\t$CCP" >> `echo "/etc/cron.hourly/$CRONFILE"`
fi