2 disks for a single search


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers 2 disks for a single search
# 1  
Old 02-01-2011
2 disks for a single search

Hi,

I have backups of my db server performed on 2 differents disks (2 crontab entries).
Every day I have to look for the latest backup file on one of both disks.

In Digital VMS we had the concept of "Directory Search List", a kind of virtual folder containing a list of folders.
Is there such a kind of solution in Unix ?

Or may by should I create a partition of these 2 disks and have a look at the partition itself ?

Thanks for any help.

Zion
# 2  
Old 02-01-2011
assume /path1 is the mountpoint for disk1, /path2 is the mountpoint for disk2
Code:
find /path1 /path2  -mtime -1 -name 'backup*' -exec ls -l {} \;

The find [path] [path] works as a search path. You can have an arbitrary number of paths.
Change the names and -mtime settings to match your needs.
# 3  
Old 02-01-2011
What Operating System and version are you running?
What filesystem type hold the files (e.g.ufs, vxfs, LVM, zfs ...)?
What Shell do you use?
What backup software are you using?
What do you normally do to "look for the latest backup file on one of both disks"?
What do you do with the information when you find it?
How much do you want to automate, and what should the automation do?


We're not sure how much experience you have of unix. There are many unix tools to help locate files. There may be features of you backup software.
# 4  
Old 02-01-2011
thanks Jim,
It works almots fine ;
find /backupMWS1 /backupMWS2 -mtime -1 -name 'ems.cmp.*' -exec ls -tc {} \;
produces:
/backupMWS1/ems.cmp.Feb01_07
/backupMWS1/ems.cmp.Feb01_11
/backupMWS1/ems.cmp.Feb01_15
/backupMWS1/ems.cmp.Feb01_19
/backupMWS1/ems.cmp.Jan31_19
/backupMWS2/ems.cmp.Feb01_09
/backupMWS2/ems.cmp.Feb01_13
/backupMWS2/ems.cmp.Feb01_17
/backupMWS2/ems.cmp.Feb01_21
/backupMWS2/ems.cmp.Jan31_21

As you can see (format name is MMMDD_HH) the files are primary sorted by folder name and then by date, if I add a |tail -1 I'm not sure to get the latest.

@Methyl :
We are using solaris 9 and ksh, about the file format i dont know, I assume it is the standart format. Backups are performed by embeded sql dumps operation in shells scripts.
dumps of main server are done every 2 hours on 2 differents disks and I must insert a crontab entry at 6AM to get the latest dumpfile and load it on a test server. This is a cheap replication procedure for developpers.
# 5  
Old 02-02-2011
Because there are no space characters in the filenames and there are not too many files we can use "ls" to sort the files by timestamp:
Code:
ls -1ctr $(find /backupMWS1 /backupMWS2 -mtime -1 -name 'ems.cmp.*' -print)

Personally I'd not use the "-c" switch to "ls" because that timestamp is not always the timestamp of file creation. It is the timestamp of the last change of the inode.
# 6  
Old 02-03-2011
I think you need to be very specific with your question so that you can get the best answers.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search Pattern and Print lines in Single Column

Hi Experts I have small query where I request the into a single file Suppose: File1: {Unique entries} AA BB CC DD FileB: AA, 123 AA, 234 AA, 2345 CC, 123 CC, 5678 DD,123 BB, 7890 (5 Replies)
Discussion started by: navkanwal
5 Replies

2. Shell Programming and Scripting

Multiple search strings replaced with single string

Hi, I need someone's help in writing correct perl code. I implemented following code for "multiple search strings replaced with single string". ========================================================= #!/usr/bin/perl my $searchStr = 'register_inst\.write_t\(' |... (2 Replies)
Discussion started by: chettyravi
2 Replies

3. Shell Programming and Scripting

Search Pattern and combine into single file

Hi Experts Please help me out with the following thing: 2 files and want the output file: {No for using FOR loop because I got 22 million lines} Tried that "It processes only 8000 records per hour" I need a faster way out !!! FileA: 9051 9052 9053 9054 9055 9056 9057 9058 9059 ... (5 Replies)
Discussion started by: navkanwal
5 Replies

4. Shell Programming and Scripting

Change to directory and search some file in that directory in single command

I am trying to do the following task : export ENV=aaa export ENV_PATH=$(cd /apps | ls | grep $ENV) However, it's not working. What's the way to change to directory and search some file in that directory in single command Please help. (2 Replies)
Discussion started by: saurau
2 Replies

5. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

6. Shell Programming and Scripting

search between keywords and make a single line

have a very big file where need to format it like below example file: abcd today is great day; search keyword 'abcd' and append to it all words till we reach ; to make it a single line. output should look like. abcd today is great day; There are many occurrence of such... (2 Replies)
Discussion started by: giri4332
2 Replies

7. Shell Programming and Scripting

Search replace strings between single quotes

Hi All, I need to serach and replace a strings between single quote in a file. My file has : location='/data1/test.log' and the output needed is location='/data2/test_dir/test.log' pls if anybody know this can be done in script sed or awk. I have a script, but it's... (6 Replies)
Discussion started by: mnmonu
6 Replies

8. Shell Programming and Scripting

Search replace strings between single quotes in a text file

Hi There... I need to serach and replace a strings in a text file. My file has; books.amazon='Let me read' and the output needed is books.amazon=NONFOUND pls if anybody know this can be done in script sed or awk.. i have a list of different strings to be repced by NONFOUND.... (7 Replies)
Discussion started by: Hiano
7 Replies

9. Shell Programming and Scripting

awk pattern match and search in single statement

Hi All, I am trying to alter all lines between EXEC SQL and END-EXEC that have an INCLUDE in them. The following code search="INCLUDE " cp -f ${WORK}/$file.in ${WORK}/$file.wrk2 for item in `echo $search `; do > ${WORK}/$file.wrk1 awk -vITEM="$item" '{ if ( $0... (3 Replies)
Discussion started by: Bruble
3 Replies

10. Shell Programming and Scripting

Search a pattern in a file with contents in a single line

Hi all I am searching for a pattern in a file . The file content is in a single line.If am doing a grep or sed for the a particular pattern am getting whole file. I want the result in different lines. attaching the file for reference search pattern "/xxxxxx/hhhh/tttttttt/sss/" and... (4 Replies)
Discussion started by: sparks
4 Replies
Login or Register to Ask a Question