scp not working saying its a directory error
I am trying to copy a file to remote server in a certain folder.
Its an adrive backup plan. But it comes with scp. I can copy the file if I don't select directory. Even if I put a directory that doesn't exist it says its a directory.
root@host1 [/usr/src]# scp ftpdelete.sh user@[email protected]:/mysql-only/
scp: /mysql-only/: Is a directory
Solution 1:
Amazingly enough in my case it was that the directory didn't exists!! :| Is the error message a bug?... or it's me. Tempted for the latter.
Solution 2:
SCP doesn't automatically create you new directory if you want to scp file (it creates directory only if you do recursive copy). There is wrong error message. The error should be No such file or directory
or similar.
It is known problem and there is upstream bugzilla about this [1].
[1] https://bugzilla.mindrot.org/show_bug.cgi?id=1768
Solution 3:
You are copying the sh
file to a new directory on the server, and the directory is expected to be there but in fact not(then the machine thinks you want to change the file to be a directory). Most probably the directory you set is wrong.
Solution 4:
-r' Recursively copy entire directories. Note that scp follows symbolic links encountered in the tree traversal.
But it doesn't create a directory but you can do below
ssh remote mkdir /diretcory
root@host1 [/usr/src]# scp -r ftpdelete.sh user@[email protected]:/complete_path/mysql-only/
or
rsync can do the creating of directory if not exist its basic command syntax is similar to scp:²
$ rsync -r -e ssh ftpdelete.sh me@my-system:/complete_path/mysql-only/
Solution 5:
scp -r source_location user@servername:/target_location