Nfs Automatic Backup Script - Rhel5

  • Uploaded by: Piyush Sachan
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Nfs Automatic Backup Script - Rhel5 as PDF for free.

More details

  • Words: 703
  • Pages: 4
MANUAL FOR AUTOMATED BACKUP THROUGH NFS --------------------------------------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 [email protected] 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: [email protected] # #Sharing data in network # DEFPERM=755 echo -e "Note: Use absolute path\n\tEnter the path of your backup folder : \c" read NFS until echo $NFS | grep -v /$ > /dev/null do echo -e "Do not use '/' at the end of backup folder name.." echo -e "Again enter the path of your backup folder : \c" read NFS done echo -e "\tAllowing a single machine for nfs share give ip : \c" read CIP if [ -z "$CIP" ]; then CIP='*' fi echo -e "$NFS\t$CIP(ro,sync)" >> /etc/exports echo -e "Default persmission $NFS will change to 755 \n\tEnter permission to modify : \c" read NFSPERM if [ -n "$NFSPERM" ]; then DEFPERM=$NFSPERM fi chmod $DEFPERM $NFS # #This will start all services related to NFS # exportfs -a chkconfig nfs on chkconfig portmap on service portmap restart service nfs restart # #Check status of nfs share # showmount -e showmount -e | grep $NFS > /dev/null STATUS=$? if [ "$STATUS" -eq 0 ]; then echo -e "NFS share is correct Now we r going to login in Slave machine" else echo -e "NFS share enteries are somehow wrong ...Program Exiting ..\nRe-run the script...!" exit fi

# #Copy client_copy.sh to slave server # echo -e "Note: For this 'sshd' service must be on slave server\n\tEnter ip of slave machine : \c" read SLIP scp client_copy.sh $SLIP:/root/ echo -e "Now you are going to login in Slave server - After login run 'sh client_copy.sh'\nType Ctrl+D to exit from Slave Server" ssh $SLIP

-----------------------------------------------------------------------client_copy.sh ------------------------------------#!/bin/bash #Automated backup - Slave machine #Date : 14-Sep-2009 #email: [email protected] # 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 chmod 755 /etc/cron.hourly/$CRONFILE # #Restarting cron daemon services # chkconfig crond on service crond restart

Related Documents

Nfs
November 2019 21
Nfs
October 2019 18
Nfs
November 2019 15
Backup
April 2020 27

More Documents from ""