I'm doing my first ever moving of user files from an old system to a new system. My goal is to use SCP for it's simple syntax of scp -r source destination
. I tried the following command to copy the files first:
scp -r root@10.0.0.11:/home/someuser/* .
In retrospect, and from past experience, this copied all files without a leading .
. In my attempt to fix this, I did this:
scp -r root@10.0.0.11:/home/someuser/.* .
meaning wildcard for anything starting with a .
. Obviously (why I'm asking the question) it didn't do what I wanted. The observed result, was that it interpreted the .
as moving up a level in the path, and it started copying /home/*
instead, also (I think) placing the files one level up from my working directory, rather than the working directory itself.
Is my interpretation of the execution of the second command correct? I think it was easy to fix since I was in ~/backup
, so one level up was ~
. I just rm -rf ~/someuser
on each username that had copied before interrupted the command. Those someuser
directories were supposed to be in ~/backup
I have since learned how to copy the files I wanted by specifying the directory only, not the files contained in the directory.
scp -r root@10.0.0.11:/home/someuser/. .
orssh root@10.0.0.11 'cd /home/someuser && tar cf - . | gzip -1' | tar zxpf -
– Stéphane Chazelas Sep 25 '22 at 16:14scp
but you could also just usersync -avhH
where theh
will account for files beginning with.
– Nasir Riley Sep 25 '22 at 17:00