Operating System - HP-UX
1838885 Members
2813 Online
110131 Solutions
New Discussion

Re: Single file from multiple locations..

 
MacMcDonald
Advisor

Single file from multiple locations..

Hi,


I need to drag backup files from over 100 different server locations to a single server. The file size and bandwidth is not an issue, i seem to be struggling with automating the process. I need to be able to pull the files (single file on each HP server, each file has the same name...) to a single location on my local server. Each file would need to be either renamed or suffixed with the ip of the originating server to identify it or saved to a separate folder on my server. I can run a batch file that will do a single server but i don’t fancy the idea of running 100 batch files,

How could i run one script that will automate the entire process?

Tall order i think but any help would be appreciated.

Regards

Mac
11 REPLIES 11
Steven E. Protter
Exalted Contributor

Re: Single file from multiple locations..

Shalom,

I would suggest rsync with the following syntax.

rsync -avH --stats -e ssh source:/home/ /backup/

Organize it any way you want, you can pull in files from many places at the same time.

If bandwidth is truly not an issue.

:-)

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Erol KAHRAMAN
Advisor

Re: Single file from multiple locations..

write a script that get the ip addresses from a file and connet to get a backup files.Also you can use these IP addresses to rename your backup files.
MacMcDonald
Advisor

Re: Single file from multiple locations..

the problem is that i can run a bat file that will connect to each server in turn and download the file but every file has the same name and each one downloaded overwrites the previous one. Is there a way i can rename them automatically, for eaxmple prefixed with the ip address of the original.
RAC_1
Honored Contributor

Re: Single file from multiple locations..

There are many ways to do it.
rsync/scp/ftp/rcp

I would prefer scp/rsync

Prepare host file. Say hosts

for host in $(do
scp/rsync ${host}:/source_path/file dest_host:/dest_path/file.${host)
# This will put file as file.hostname on destination.

done

you can some error checking as required.
There is no substitute to HARDWORK
Peter Godron
Honored Contributor

Re: Single file from multiple locations..

Mac,
quickly written script, so may have a few hiccups:

#!/usr/bin/sh
remote_file="fred.lis"
location="/data/directory"
while read address user pass
do
echo "#!/usr/bin/sh" > ftpscript.sh
echo "ftp -n $address < EOF" >> ftpscript.sh
echo "user $user $pass" >> ftpscript.sh
echo "cd $location" >> ftpscript.sh
echo "get $remote_file ${address}_${remote_file} >> ftpscript.sh
echo "quit" >> ftpscript.sh
echo "EOF" >> ftpscript.sh
chmod 777 ftpscript.sh
./ftpscript.sh > ftpscript.log 2>&1
done < ip_address.lis

You just need a file (ip_address.lis) with:
ip_address username password

Please change the location and remote_file names at beginning of script.
MacMcDonald
Advisor

Re: Single file from multiple locations..

Many thanks for the replies. Im pretty new to all of this at your solutions seem to be a little to complicatedfor my tiny head to get around. I have a vb script running that now downloads all of the required files and I can rename them. But is there anyway i can auto rename them to include the ip address of the server they came from?.. e.e

get /bin/prd/full_format.dft "%localhost%c:\test\full_format,dft

I would hope this would give me a filename of 22.22.22.222full_format_dft

I am guessing I am way of the mark with this...
Patrick Wallek
Honored Contributor

Re: Single file from multiple locations..

Are you doing this from a Windows machine by chance? You said 'VB Script' and I don't think those run on HP-UX servers themselves.

MacMcDonald
Advisor

Re: Single file from multiple locations..

all the 100 servers are HP Servers, but i need to tun the script from a windows machine.
OldSchool
Honored Contributor

Re: Single file from multiple locations..

well, the "get" in previous post looks like you're using ftp to pull the file?

If so, the yes, ftp can rename the file on the fly for you, the syntax would be:

get source_file_name dest_file_name

now, as the the mechanics of getting VBScript to do this, (and the variable substitution) you might have better luck in a "Window" forum.
MacMcDonald
Advisor

Re: Single file from multiple locations..

Yep - i'm happy with all of that - but i need the ip address of the unix box the file came from to be appended to the new file name.
OldSchool
Honored Contributor

Re: Single file from multiple locations..

well since the "dest_name" doesn't have to match the "source_name" in the "get", you're good to go there.

so, asking:

how do I determine the IP address? or
how do I get it in the "dest_name"

as noted in one of the previous posts, I'd have a file w/ all of the IPs I need to connect to and loop thru it with something that does the equivalent of this in VB

cat iplist | while read ip_addr
do

ftp $ip_addr<get a ${ip_addr}.a
EOF

done

But, as I said above, I don't know the mechanics of doing this in VB......