LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-02-2009, 07:25 AM   #1
rajeshkumar.dba
LQ Newbie
 
Registered: Jun 2009
Posts: 1

Rep: Reputation: 0
Shell script to copy database archivelogs sequentially from one directory to another


Hi Friends,
I am a dba and new to scripting and i want to write a shell script to copy database archivelog files sequential from one directory to another directory within a server. I am hereby enclosing the sample archivelog file name.

Archive log filename : log_0000118432_1.arc (Here number 0000118432 will be sequentially incremented by 1 for next filename).

Here the catch is all Archivelogs must be copied to destination directory. Previously copied files should not be copied. Any help or layout of this script would be much appreciated. Thanks a lot in advance.

Regards,
Rajeshkumar
 
Old 06-02-2009, 08:01 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Quote:
Previously copied files should not be copied
You should use the rsync command to copy the files if the previously copied files are still in the target directory. It can do many things and most commonly is used to keep two directories in sync. It only copies in the differences and can even be used to delete files in the target that no longer exist in the source if you want.

Type "man rsync" for details.
 
Old 06-02-2009, 08:12 AM   #3
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
awk 'BEGIN{
  destination="/tmp/"
  q="\042"
} 
function exists(file,        dummy, ret) {
   ret=0;
   if ( (getline dummy < file) >=0 ) {ret = 1; close(file)};
   return ret;
}
{
  if ( exists(destination FILENAME) ){
    print "file "FILENAME " exists..not copying..."
  }else{
    cmd="cp "q FILENAME q " "destination 
    cmd|getline result
  }

}' log*.arc
 
Old 06-02-2009, 08:12 AM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
deleted...

Last edited by ghostdog74; 06-02-2009 at 08:15 AM. Reason: double post...strange
 
  


Reply

Tags
scripting, shell


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script to insert value in database deepu_linux Programming 14 04-25-2013 12:07 PM
mulitple copy a existing directory and rename it at the end sequentially in BASH neo2k Linux - Newbie 2 08-20-2008 10:45 AM
Shell Script: want to insert values in database when update script runs ring Programming 2 10-25-2007 10:48 PM
shell script: delete all directories named directory.# except directory.N brian0918 Programming 3 07-13-2005 06:54 PM
Shell script to copy file name with part of directory Transition Linux - General 5 01-18-2005 05:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration