1828884 Members
2755 Online
109985 Solutions
New Discussion

Copy Ignite images

 
Francis Flan
Regular Advisor

Copy Ignite images

Hi,

My scripting skills are rusty from and I need some pointers.
I need a simple shell script that copies my Ignite images to another server and removes the previous Images before the copy operation starts.

Any help appreciated.
Francis
16 REPLIES 16
Francis Flan
Regular Advisor

Re: Copy Ignite images

Here's what I was thinking:

#!/usr/bin/ksh
rm IgniteServer_IP:/path_to_ignite/2009*

I want to copy only the most recent image (created within 48hrs) since i keep the last two ignites. How would I use the find command to select this?
Something like this perhaps?
find . -type f -mtime 2 -exec cp....
Dennis Handly
Acclaimed Contributor

Re: Copy Ignite images

>I want to copy only the most recent image (created within 48hrs). How would I use the find command to select this?
>find . -type f -mtime 2 -exec cp

You would use: -mtime -2
-mtime 2 is for 2 to 3 days.
Francis Flan
Regular Advisor

Re: Copy Ignite images

Thanks Dennis.
Could you complete this last line to copy the file?

Something like this perhaps:

find . -type f -mtime 2 -exec cp {} /ignite/source_image destination_IP:/dir/
Ivan Krastev
Honored Contributor

Re: Copy Ignite images

By default make_net_recovery keep 2 archives. See the man page:

-n number_archives
Specifies the number of archives that should remain on the server at any given time. The default is two (2)

regards,
ivan
Dennis Handly
Acclaimed Contributor

Re: Copy Ignite images

>Could you complete this last line to copy the file?
find . -type f -mtime 2 -exec rcp {} destination_IP:/dir/ +

I'm not sure -exec will work and you may have to write a script:
#!/usr/bin/ksh

rcp $* destination_IP:/dir/


With a script, you can also remove the files after copying them.
Suraj K Sankari
Honored Contributor

Re: Copy Ignite images

Hi,
>>find . -type f -mtime 2 -exec cp {} /ignite/source_image destination_IP:/dir/

1) . will search your file from root directiory insted of . you can give your source path /ignite or where your file is resaiding.
2) cp will not copy your file one server to other in this case you have to use scp or rcp to copy your file into another server.

find /opt/ignite/ -type f -mtime 2 -exec rcp destination_IP:/dir ()\;

Suraj
Francis Flan
Regular Advisor

Re: Copy Ignite images

I've tried both of these and they execute without errors but no files are copied.

find /var/srcdir/ -type f -mtime 2 -exec rcp dest_ip:/var {}\;
find /var/srcdir/ -type f -mtime 2 -exec rcp {} dest_ip:/var \;
James R. Ferguson
Acclaimed Contributor

Re: Copy Ignite images

Hi Francis:

> I've tried both of these and they execute without errors but no files are copied.

find /var/srcdir/ -type f -mtime 2 -exec rcp dest_ip:/var {}\;
find /var/srcdir/ -type f -mtime 2 -exec rcp {} dest_ip:/var \;

What happens if you simply do:

# find /var/srcdir/ -type f -mtime 2 -print

...do you in fact, get any output? Using an unsigned argument to '-mtime' means _EXACTLY_ two (2) in this case. You probably want to use:

# find /var/srcdir/ -type f -mtime +2 ...

As Dennis noted, making the '-exec' argument a script that does the copy and then on success _removes_ the copied file is probably the desired approach.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: Copy Ignite images

>JRF: Using an unsigned argument to '-mtime' means _EXACTLY_ 2

Exactly 2 days means: 2 <= X < 3 days
Anywhere from 48 to one second less than 72 hours. With -2 and +2 on each of the two sides. Unless you use UNIX95=FIDDLE_WITH_FIND_TIMES:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1306285
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1271016
James R. Ferguson
Acclaimed Contributor

Re: Copy Ignite images

Hi (again):

> Dennis: Exactly 2 days means: 2 <= X < 3 days

Yes, that's true and probably expressed better than the manpages for 'find' discuss the n, -n and +n arguments. My point, however, was that Francis may be not have realized that using 'n' alone might too strictly restrict his expectations.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: Copy Ignite images

>JRF: that's true and probably expressed better than the manpages for 'find' discuss the n, -n and +n arguments.

It is expressed better because the manpage is broken and documents the UNIX95=FIDDLE_WITH_FIND_TIMES option, not the default.

>My point was that Francis may be not have realized that using 'n' alone might too strictly restrict his expectations.

Yes, I already mentioned that, so I assumed that wasn't your point.
James R. Ferguson
Acclaimed Contributor

Re: Copy Ignite images

Hi (again):

> Dennis: It is expressed better because the manpage is broken and documents the UNIX95=FIDDLE_WITH_FIND_TIMES option, not the default.

OK, then how about getting the 'find()' manpages improved? You have been able to jump-start issues like this before :-)

Regards!

...JRF...
Francis Flan
Regular Advisor

Re: Copy Ignite images

find /var/srcdir/ -type f -mtime -2 -print returns with the correct file.
(I hadn't heard of minus values for -mtime before)

Adding the -exec rcp part at the end and is coming back with
find /var/srcdir/ -type f -mtime -2 -exec rcp dest_ip:/dir {} \;
remshd: Couldn't look up address for your host
remshd: Login incorrect.

The hosts files on both servers are correct and they resolve just fine.
inetd.
inetd.conf has
kshell stream tcp6 nowait root /usr/lbin/remshd remshd -K
klogin stream tcp6 nowait root /usr/lbin/rlogind rlogind -K

Do I need .rhosts and hosts.equiv files to use rcp?
Steven E. Protter
Exalted Contributor

Re: Copy Ignite images

Shalom,

You ask: Do I need .rhosts and hosts.equiv files to use rcp?

These files may need to be changed if the name resolution environment is different at restore time.

I find it easier to move these files around as tar files personally. You could still use the find commands to pick and build the tar files.

I found rcp sometimes introduced errors which compromise the integrity of the ignite backups.

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
James R. Ferguson
Acclaimed Contributor

Re: Copy Ignite images

Hi :

> Do I need .rhosts and hosts.equiv files to use rcp?

Yes, see the manpages for 'rcp'.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: Copy Ignite images

>JRF: how about getting the 'find' manpages improved? You have been able to jump-start issues like this before :-)

If you looked at threadId=1271016, you'll see you already thanked me for that. :-)