I want to copy my environment files in the dir .env/
from my local machine to my remote machine.
According to this answer, I tried the following but got an error:
stephen@desktop:~/Projects/finance$ scp -r .env root@<MY_IP_INSTANCE>:/finance
scp: /finance/.env: Not a directory
I verified the directory exists on my local machine:
stephen@desktop:~/Projects/finance$ ls -al | grep .env
drwxrwxr-x 2 stephen stephen 4096 Nov 12 14:25 .env
And I verified it does not exist on my remote machine:
root@localhost:~/finance# ls -al |grep .env
root@localhost:~/finance#
According to the online resources, the source path should remove the trailing /
from the file path if I want to copy the entire folder. I've hit insanity where I've tried every combination of source and destination paths.
EDIT: Here is the linode docs which is the VPS I am using. Seems like conflicting information.
EDIT2: Here is what worked
stephen@desktop:~/Projects/finance$ scp -r .env [email protected]:finance
.dev.local 100% 712 20.0KB/s 00:00
.prod 100% 595 21.2KB/s 00:00
.prod.local 100% 710 24.7KB/s 00:00
.dev 100% 597 20.2KB/s 00:00
CodePudding user response:
You need to remove the slash. What you wrote refers to the root folder on the other machine. From your verification steps it's clear though that you meant the home folder of root (/root
):
scp -r .env root@<MY_IP_INSTANCE>:finance
# or, explicitly
scp -r .env root@<MY_IP_INSTANCE>:/root/finance
CodePudding user response:
You need to provide the path as /usr/{username}/Projects/finance.
So your command should be
scp -r .env root@<MY_IP_INSTANCE>:/usr/{yourUserName}/Projects/finance
you can find the path by going to the finance folder and running
pwd
By default the path being used is /finance instead of the ~/finance which means it is looking for the finance folder in the root directory('/').