We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,633 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Scp Script?

Hi,
I would like to write a script to scp files from 1 server to other but the problem is if scp fails maybe because of server crash or somthing like that, i would like to start scp from the last file. i dont want to copy all the files again. Any ideas?

Thanks
Manuj

3
Contributors
3
Replies
2 Days
Discussion Span
4 Months Ago
Last Updated
6
Views
manujkathuria
Newbie Poster
3 posts since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

hi,

it depends on how you intend to scp files
if you scp them all at one time, a bit like you'd copy recusrsively directories, AFAIK you can't tell.
if you copy file on at a time, using a loop, you could echo filenames to a log file when scp fails
something like this, but it's much longer

for file in ./*
do
   scp "$file" user@server || echo "$file" >>logfile
done

more or less.

Watael
Junior Poster
121 posts since Apr 2012
Reputation Points: 4
Solved Threads: 26
Skill Endorsements: 2

You could start by issuing a directory listing of the files you'd like to copy

ssh user@server "ls -l"

Using that list you can evaluate how many files have been copied (by checking against your local listing) and only request the ones you do not have.

N.B. This will not consider the case where files on the remote server change after they are copied by the client.

L7Sqr
Practically a Posting Shark
849 posts since Feb 2011
Reputation Points: 253
Solved Threads: 155
Skill Endorsements: 7

On second thought, why not just use rsync

L7Sqr
Practically a Posting Shark
849 posts since Feb 2011
Reputation Points: 253
Solved Threads: 155
Skill Endorsements: 7

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0639 seconds using 2.67MB