Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login into a remote server

Status
Not open for further replies.

md1750

MIS
Apr 18, 2001
80
US
My task is to login to a remote Solaris server,cd into a directory and execute a backup shell script and scp the log files to a directory on workstation many miles away.I donot know where or how to start.Any assistance is appreciated
 
Write a script on the remote Solaris server to do everything and call the script remotely with the "rsh" command (see "man rsh"). If the workstation where the log files are supposed to end up is a Unix workstation then your script can copy the files there with "rcp" (see "man rcp").
 
I am new to script writing and any help as to how to start is appreciated.
 
1) do you already have the backup script on the remote server ?

2) I see you have scp so I'll assume you have ssh (secure shell) If so you can do ssh user@remoteserver name_of_backup_script.sh

This will prompt you for the users password and then run the backup script.

3) Depending on how your backup script works (lets say it creates a tar file [fred08012003.tar]) then you can have another script (or as part of the backup) to ftp the file to you.
ssh user@remoteserver name_of_backup_script.sh; ftp_script.sh

If thats the case why login? just set a crontab to run the two scripts for you!

AND FINALLY:
4) if you have neither 1, 2, 3 then "allthough very basic" maybe these will help:

------------------------------------------------------------
Weekly_backup.sh
#!/bin/ksh
#
# NAME: Weeklybackup.sh
# TASK: To do level 0 backup
# CODE: Laurie Baker
#
# To Rewind the tape add...
#
# mt -f /dev/rmt/0 rewind
#
# Back up the local disks /, /usr, /.bigpart, /opt
#
#
# Set-up the lists of volumes to backup
#
UFSDUMPLISTLOCAL="/ /usr /.bigpart /opt"

VXDUMPLISTLOCAL=""


LOCALMACH=localhost
DUMPLOG=`date '+%d%b%Y'`
DUMPLOG="/backups/logs/dumplog$DUMPLOG.log"
cat /dev/null > $DUMPLOG

echo " ¬¬¬ CAUTION! ¬¬¬"
echo " ****** SYSTEM BACKUP IN PROCESS ******"
echo "+++++++ LAurie BAker ++++++++"

for i in `echo $UFSDUMPLISTLOCAL`
do
echo "****** $i ******"
/usr/sbin/ufsdump 0fcu /dev/rmt/0cn $i >> $DUMPLOG 2>&1
done
# Note: change device if writing to disk

#
# Backup the shared disks
#
for i in `echo $VXDUMPLISTLOCAL`
do
echo "****** $i ******"
/usr/sbin/vxdump -0fcus /dev/rmt/0cn 87040 $i >> $DUMPLOG 2>&1
done



#
# Backup other local disks (uncomment if required)
#
# for i in /etc/opt/SUNWcluster/conf/ccdssa
# do
# echo "****** $i ******"
# /usr/sbin/ufsdump 0fcu /dev/rmt/0cn $i >> $DUMPLOG 2>&1
# done
mt rewoffl
# Uncomment next line to reboot if required
#/usr/sbin/init 6
-----------------------------------------------------------

NOTE this backup is for output to tape so needs changing if you need to write to disk :¬)

AND
------------------------------------------------------------
FTP_TO_HOME.sh
#!/bin/sh
Date=`/usr/bin/date '+%Y%m%d'`
Filelocation=/path_to/backup.file
host=someftphost.com
local=/u01/backups
login_name=someuser
password=somepassword
cp $Filelocation $local/$Date.backup
/usr/bin/gzip $local/*
cd $local
ftp -v -n $host << EOF
user $login_name $password
prompt
bin
mput *
quit

EOF
rm -f /u01/backups/*
------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top