Operating System - HP-UX
1844734 Members
2315 Online
110233 Solutions
New Discussion

File archiving tar find for files that are current

 
SOLVED
Go to solution
Belinda Dermody
Super Advisor

File archiving tar find for files that are current

Is there a way that I can use a combination of sh commands to archive files that were created less than 24 hours ago. I have a bunch of indexs that are updated using networker(I have 60 days worth) and I would like to archive the current ones after the nightly backup. The whole directly is 18gig and I would like once in a while just to do the current ones which would only take a few minutes instead of 4 hours. Using the find command looks like it uses the 24 hour break and these indexs are created around 2:30 AM and I would back them up around 7AM each morning.
14 REPLIES 14
Pete Randall
Outstanding Contributor

Re: File archiving tar find for files that are current

James,

You can use the touch command to create a reference file with a specifed date and time. Then you can use find with -newer option to find the files more recent than the reference file.


Pete

Pete
RAC_1
Honored Contributor

Re: File archiving tar find for files that are current

Prepare a cron job that will create a file at 02:30AM. Then you can use find command with -newer option to get the list of the files that are created after that.

There is no substitute to HARDWORK
Belinda Dermody
Super Advisor

Re: File archiving tar find for files that are current

Pete thanks for you response, I tried it but here is my results. Although I touched a file named refffile with 1 minute past midnight, the find command comes back with all the files.



root other 0 Feb 12 00:01 reffile
cuba2:/nsr/index> find . -newer reffile -exec ls -l {} \; |more
total 0
drwxr-xr-x 3 root other 96 Mar 13 2001 abaco
drwxr-xr-x 3 root root 96 Feb 28 2003 disko
drwxr-xr-x 3 root root 96 Jan 31 2002 duke
drwx------ 3 root root 96 Feb 12 06:41 everest
drwxr-xr-x 3 root other 96 Oct 8 2001 folly
ns.com
drwxr-xr-x 3 root root 96 Mar 13 2001 java
drwxr-xr-x 5 root other 96 Mar 13 2001 zurich
total 16568
-r--r--r-- 1 root other 236 Feb 5 01:02 4021dc68.k0
-r--r--r-- 1 root other 192 Feb 5 01:02 4021dc68.k1
-r--r--r-- 1 root other 3660 Feb 5 01:02 4021dc68.rec
-r--r--r-- 1 root other 1148 Feb 5 01:35 4021dc73.k0
-r--r--r-- 1 root other 828 Feb 5 01:35 4021dc73.k1
-r--r--r-- 1 root other 17344 Feb 5 01:35 4021dc73.rec
-r--r--r-- 1 root other 1004 Feb 5 02:38 4021e44f.k0
-r--r--r-- 1 root other 768 Feb 5 02:38 4021e44f.k1
-r--r--r-- 1 root other 10784 Feb 5 02:38 4021e44f.rec
-r-------- 1 root other 204 Feb 5 02:05 4021eb3b.k0
Robert-Jan Goossens
Honored Contributor
Solution

Re: File archiving tar find for files that are current

Hi,

find . -newer reffile -type f -exec ls -l {} \; |more

Robert-Jan
Pete Randall
Outstanding Contributor

Re: File archiving tar find for files that are current

James,

I tried it as well and noticed some inconsistent results unless I restricted it to just files with -type f (as Robert-Jan suggested). Try that and see what you get!


Pete

Pete
Patrick Wallek
Honored Contributor

Re: File archiving tar find for files that are current

You have to be careful with find and ls. If the result of the find command is a *directory* then you will do an 'ls -l dirname' which will list all files in that directory which is not necessarily what you want.

A couple of ways around this are: 1) use the '-type f' argument to find to only look for files. 2) when doing the ls use 'ls -ld' to restrict the ls to just showing the dirname and not the contents of the directory.
Michael Schulte zur Sur
Honored Contributor

Re: File archiving tar find for files that are current

Hi,

what about:
find /directory -mtime -1 -print
?

Michael
Michael Schulte zur Sur
Honored Contributor

Re: File archiving tar find for files that are current

Oops,

should be:
find /directory -mtime -1 -type f -print

Michael

Pete Randall
Outstanding Contributor

Re: File archiving tar find for files that are current

Ahhh, but Michael, that's the problem as originally described:

"the find command looks like it uses the 24 hour break"


Pete

Pete
Michael Schulte zur Sur
Honored Contributor

Re: File archiving tar find for files that are current

Hi Pete,

"the find command looks like it uses the 24 hour break"

I am sorry, but this eludes my English. ;-)
You forget, me German! ;-))

What does it mean?

Michael
Pete Randall
Outstanding Contributor

Re: File archiving tar find for files that are current

Michael,

Loosely translated, it means that -mtime +1 will match files created between midnight yesterday and midnight the day before. James was looking for a solution that would identify only the files created within the last 24 hours: from 7:00 AM this morning to 7:00 AM yesterday morning.

Hope that helps!


Pete

Pete
Michael Schulte zur Sur
Honored Contributor

Re: File archiving tar find for files that are current

Hi Pete,

I understood so.

He, that is able to read, is in the advantage! If you read carefully my post, you will notice, that I said -mtime -1 and not -mtime +1. :^)

-mtime -1 gets all files younger than 24h

Michael
Mark Ellzey
Valued Contributor

Re: File archiving tar find for files that are current

Hi,

As an alternative to the suggestions already made, you could use fbackup to take a full backup of your indexes, then use the incremental function of fbakup to get only the changed (or new) files.

See man fbackup.

Regards,
Mark
Belinda Dermody
Super Advisor

Re: File archiving tar find for files that are current

Thanks Marc, I am a administrator for several HP servers and a bunch of Sun Solaris system running networker (the worse possible backup solution you could use), I love the fbackup and frecover of the HP-UX systems.