Backup script in ksh

I need a script in ksh that
-automatically connect to computers in a network and identify directories in remote computers
-then mount directories on to the local host where the script is runned
-then backup directories in the local host and the remote systems one by one using tar command (to archive) on to local host.

What have you tried? Where are you stuck?

Is this homework?

I have a script that takes input from the user for path and IP.....but i need a script that automatically mount directories form remote systems.

Only NFS-exported file systems can be mounted.
If you have Solaris/Linux/HP-UX automounter running and /net -hosts in /etc/auto.master (or /etc/auto_master), you should be able to discover and backup the exported NFS, like this example

date=`date +%Y-%m-%d-%H-%M`
cd /net || exit
tar cf /path/to/archive/$date.tar remotehost1 remotehost2

Or a loop

date=`date +%Y-%m-%d-%H-%M`
cd /net || exit
for h in remotehost1 remotehost2
do
  tar cf /path/to/archive/$h.$date.tar $h
done
1 Like

I have this script and i'm getting some error....please check and let me know if any corrections have to made

#!/bin/ksh

MOUNT=/bin/mount
UMOUNT=/bin/umount

DEST_PATH=/bin/backup

GetPathRemote(){
for ip in 192.168.1.{1..254};
do
if[ nc -zv $ip 22 2>$1 | grep succeeded ];
then
ksh $ip "ISMOUNTED=`$MOUNT | grep "/mntback"`"
fi

if[ ! "$ISMOUNTED"="" ];
then
mkdir/mntback
fi

DEST_NAME=backup

DEST_PATH=/mntback/$DEST_NAME

CreateArch
$UMOUNT/mntback
done
}

What error?

The thing is I need a script that automatically get IP for different systems in the network and mount directories from that systems.

Yes, OK, but what is the literal error message that you are getting?

One problem lies in the two lines cited below:

They contain a simple syntax error which you should have noticed if you'd have been able to write this script. I suppose you haven't. You have copied it from somewhere and probably copied it badly. You haven't even bothered to look at the error message, because otherwise it would have immediately dawned on you what is wrong.

Please note, that this forum is "help to help yourself", not "do my work for me".

bakunin