LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-17-2008, 03:26 PM   #1
rev1976
LQ Newbie
 
Registered: Nov 2007
Posts: 3

Rep: Reputation: 0
SCP files from one server to another


Hi all,

I need to scp files (DB2 backup files) from one server (A) to another server (B) and I would like to automate this. What i need to do is to find the files older than 11 days and scp those files to the other server. And then i need to delete the files on server (A) that were sent over. Any help would be greatly appreciated. So far i have the this command:

find /data/db2inst1/backup -name "*.0.db2inst1.NODE0000.CATN0000.*" -mtime +11 -type f -exec scp {} <server(B)>:<server(B) directory> \; -print

So this will find the files 11 days or older and scp them over to server (B). Please let me know if this is correct or if there's another way to do it. Thank you.
 
Old 09-17-2008, 03:36 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,184

Rep: Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403
Quote:
Originally Posted by rev1976 View Post
Hi all,

I need to scp files (DB2 backup files) from one server (A) to another server (B) and I would like to automate this. What i need to do is to find the files older than 11 days and scp those files to the other server. And then i need to delete the files on server (A) that were sent over. Any help would be greatly appreciated. So far i have the this command:

find /data/db2inst1/backup -name "*.0.db2inst1.NODE0000.CATN0000.*" -mtime +11 -type f -exec scp {} <server(B)>:<server(B) directory> \; -print

So this will find the files 11 days or older and scp them over to server (B). Please let me know if this is correct or if there's another way to do it. Thank you.
I can't test it right now, but it looks good to me.

However, anytime file deletions are automated, I get nervous. Since I've been snakebit by this before ("What? You deleted them? Yeah, I know I said you could, but I really need it NOW!"), I'd probably do a move on the file to another drive/partition, where they could sit unnoticed. If someone complained or needed one, I'd have it quickly available. If not, I'd probably go out there every now and then, and nuke things older than a month or so....
 
Old 09-17-2008, 07:45 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,406

Rep: Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396
Actually, if he's got a copy on another server I wouldn't worry too much. I would gzip or bzip2 the files unless they are being actively used. Saves on disk space.
I'd also tend to do it in a loop rather than as a one-liner, as you can then add other cmds easily eg email conf list of which files got copied, or email error msg if failure...
This sounds like its going to end up as a cron job.

Last edited by chrism01; 09-18-2008 at 08:20 PM.
 
Old 09-18-2008, 08:13 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,184

Rep: Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403Reputation: 4403
Quote:
Originally Posted by chrism01 View Post
Actually, if he's got a copy on another server I wouldn't worry too much. I would gzip or bzip2 the files unless they are being actively used. Saves on disk space.
Agreed on the compression, but I *ALWAYS* worry about deleting a file. I've had them get corrupted, or have some goober delete them from the backup location. If I have the space, I make more copies.
 
Old 09-18-2008, 08:21 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,406

Rep: Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396
In the long run offline backups are de-rigeur, pref off-site.
 
  


Reply


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
scp large files error sburns76247 Linux - Security 1 03-22-2005 05:23 PM
copy files....using scp help me suguname Mandriva 2 01-26-2005 01:14 AM
copy files....using scp help me suguname Mandriva 5 01-25-2005 05:42 AM
scp slow for tar files? kloppster Linux - Software 4 08-21-2004 08:14 PM
problem sending files with scp illiniguy3043 Linux - Newbie 1 06-27-2004 10:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:00 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration