Backup Script – Interactive

 

Interactive backup script

You can modify this script according to you need. When you execute this script first it will ask for the hostname from where you want to copy then user name (as what user you want to copy), then hostname where you want to backup, then user name as which user you want to backup then give the name of the directory which you want to copy and at last give name of the directory where you want to backup.

#/bin/bash
#   MAKE SURE THE USER HAS RIGHT PERMISSIONS TO ACCESS AND COPY THE DIRECTORY ON THE REMOTE MACHINES. ROOT SOLVES EVERYTHING 🙂

echo " Enter the hostname or ip from where you want to backup"
read HOST_1
echo " Enter the username that you want to login as"
read USER_1
echo " Enter the hostname or ip where you want to backup"
read HOST_2

echo "Enter the username for this host"
read USER_2
ercho "Enter the folder you want to backup. Ex: /etc,/root,/home/user"
read DIR
echo "Enter the destination path where you want to backup"
read PATH
ssh $USER_1@HOST_1 "scp -r $DIRECTORY $USER_2@HOST_2:$PATH"





BY Rajesh Kunwar

 

 

 

Leave a Reply