1752794 Members
5776 Online
108789 Solutions
New Discussion юеВ

Re: 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