0

I'm copying a website from remote server to another and I have

SOURCE SERVER /var/www/vhosts/namesiteA.com /FolderA /FolderB DESTINATION SERVER /var/www/vhosts/namesiteB.com 

After running the following bash:

#!/bin/bash SOURCE="[email protected]:/var/www/vhosts/namesiteA.com/" DESTINATION="/var/www/vhosts/namesiteB.com/" sshpass -p "<source_server_pass>" scp -p -r "$SOURCE" "$DESTINATION" 

works fine, but I expect:

DESTINATION SERVER /var/www/vhosts/namesiteB.com /FolderA /FolderB instead I get: /var/www/vhosts/namesiteB.com /namesiteA.com /FolderA /FolderB 

1 Answer 1

2

With the new SFTP-based protocol for scp you need a trailing . on the source directory path:

SOURCE="[email protected]:/var/www/vhosts/namesiteA.com/." 

Unfortunately if you're using a legacy version of scp that uses the old scp protocol, and it's new enough to be updated with a fix for CVE-2018-20685, the trailing dot will break the copy. See scp: error: unexpected filename

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.