If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > How to create scp script?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-16-08, 10:33
rev1976 rev1976 is offline
Registered User
 
Join Date: Dec 2007
Posts: 78
How to create scp script?

Hi everyone,

I need to create a script that will scp DB2 backup files greater than 3 days from one server to another. The only problem is that the DB2 databases get backed up using the db2 instance and we sudo to the instance hence we don't know the password. Is there anyway to send it using a user id? any help would be greatly appreciated. I am running DB2 V9 on a Linux Intel platform. Thanks again.
Reply With Quote
  #2 (permalink)  
Old 09-16-08, 11:56
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You can use ssh to run a "find" command and identify all the files you want to copy via scp. Then you feed the result through a loop and grab each file.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 09-16-08, 12:00
rev1976 rev1976 is offline
Registered User
 
Join Date: Dec 2007
Posts: 78
Thank you. Sorry i a newbie when it comes to shell scripts would you happen to have the syntax?
Reply With Quote
  #4 (permalink)  
Old 09-17-08, 03:21
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Have a look at the man pages of ssh, scp, and find.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 10-15-08, 10:25
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
talk to your UNIX admin and see if they can NFS mount directory from another server so you can simply move file there.

find put_your_original_dir_here -type f -mtime +3 -exec mv {} put_your_dist_dir_here \;

it will be a one line script.

And do what Stolze said as well
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On