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. |
Quote:
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.... |
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. |
Quote:
|
In the long run offline backups are de-rigeur, pref off-site.
:) |
All times are GMT -5. The time now is 07:01 PM. |