Operating System - HP-UX
1825747 Members
2675 Online
109687 Solutions
New Discussion

Re: How to take backup of modified files

 
yogesh kumar_2
Frequent Advisor

How to take backup of modified files

Hi,
I have one script in my machine,so if i run that script means it will display only modified files.The following format is shown below.

M /te/yogesh/stm/trs/as/xxx.cpp
M /te/yogesh/foundation/trs/as/xxx.isd
M /te/rajesh/turbo/rim/xxx.h
M /te/rajesh/turbo/misc/xxx.h

So the above modified files(i,e with absolute path)i am getting.So i want to copy those modified files with that absolute path in to my destination path (i,e/net/cse-ben/backup)

Can any one tell me how to do scripting in this issue.So that it will be helpful for my script.
10 REPLIES 10
Sandeep_Chaudhary
Trusted Contributor

Re: How to take backup of modified files

find . -mtime +1 -print | cpio -ov > /net/cse-ben/backup/tree.cpio


change the find command sysntax as per ur need
yogesh kumar_2
Frequent Advisor

Re: How to take backup of modified files

Hi choudary,

Suppose if i want to take modified files from /ae directory.What command i have to execute.
Sandeep_Chaudhary
Trusted Contributor

Re: How to take backup of modified files

find /ae -mtime +1 -print | cpio -ov > /net/cse-ben/backup/tree.cpio
yogesh kumar_2
Frequent Advisor

Re: How to take backup of modified files

Its showing following error

Truncating inode number
/ae
1 block

Sandeep_Chaudhary
Trusted Contributor

Re: How to take backup of modified files

create an archive with:

find /ae +mtime +1 -print|cpio -ovcBO

restore archive with

cpio -ivcI

-c option should avoid this error
yogesh kumar_2
Frequent Advisor

Re: How to take backup of modified files

Hi first i checked the modified files.I use the following commands.

find /ae .mtime +1 print | more

But it is displaying each and every files inside that /ae directory

Sandeep_Chaudhary
Trusted Contributor

Re: How to take backup of modified files

man find


-mtime n True if the file modification time subtracted
from the initialization time is n-1 to n
multiples of 24 h. The initialization time
shall be a time between the invocation of the
find utility and the first access by that
invocation of the find utility to any file
specified in its path operands.
yogesh kumar_2
Frequent Advisor

Re: How to take backup of modified files

+1,-1,1=what does it mean
Peter Nikitka
Honored Contributor

Re: How to take backup of modified files

Hi,

no need for an additional find, when you have the file list already!
Just drop the leading 'M /' to get a relative pathname suitable for restoring under your destination path:
cd /
sed 's:^M /::' inputfile | cpio -pdmv /net/cse-ben/backup

The 'cpio' will preserve the directory structure at the destination - for additional options see 'man cpio'.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
James R. Ferguson
Acclaimed Contributor

Re: How to take backup of modified files

Hi:

> +1,-1,1=what does it mean

See the manpages for 'find'. '+n' means more than 'n'. '-n' means less than 'n'; and 'n' means exactly 'n'. In this case, 'n' is in the units of one day (measured as 24-hours).

Regards!

...JRF...