Reputation: 198
I would like to copy a directory of files from a remote server. As it is a large number of files, the option of ignoring existing files on the destination server is desirable. Unfortunately, rsync is not available for some reason (the remote server is from a CDN service, and beyond my control). So I think I am stuck using scp -r on the folder in question.
Is there anyway of doing this with ignoring existing files?
thanks
Upvotes: 2
Views: 2443
Reputation: 1343
SCP needs a writable file so that it can replace that file.
Using this, for the files which you do not want to replace, you can remove the permission to write for them. And continue with your scp for all files.
https://unix.stackexchange.com/a/51932/284063
Upvotes: 0
Reputation: 10244
It's easy to write an script in Perl to do that using the module Net::SFTP::Foreign:
#!/usr/bin/perl
use Net::SFTP::Foreign;
my $sftp = Net::SFTP::Foreign->new('user@host');
$sftp->die_on_error;
$sftp->rget('/remote/path', '/local/path',
resume => 'auto',
on_error => sub { my ($sftp, $e) = @_;
warn "error processing $e->{filename}: "
. $sftp->error;
}
);
Upvotes: 1
Reputation: 95499
You could also create a *.tar.gz or *.tar.bz2 archive, scp it, and then unpack it. I don't know if scp -r
uses any compression. If not, compressing everything first might, potentially, make it faster.
Upvotes: 1