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

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.

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.

On second thought, why not just use rsync

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.