The article describes ways of copying content over network.
When upgrading a home server, I copy all the data from the old server to a new system. In the examples below, I work from the new server and both servers are on the same subnet:
Both the ssh
and scp
commands communicate over a secure connection (TCP port 22). Please note that you need to enable the sshd
daemon on the remote host.
If you need to copy single files or directories, you can use the scp
command:
scp -r -v -p root@192.168.0.1:/etc /local_dir
Flag explanation:
/etc
including its subdirectories)
In the example above we copy the /etc
directory located on a remote host (the old server: 192.168.0.1) to /local_dir
on the local host (“new” server).
Please note that the scp
command cannot copy the whole file system hierarchy including /proc
, /dev
or /lost+found
. Fortunately, there is a workaround which was provided by Patrick Volkerding.
The following command should successfully copy a whole filesystem hierarchy:
ssh root@192.168.0.1 "(cd / ; tar cf - . )" | (mkdir -p /local_dir ; cd /local_dir ; umask 000 ; tar xvf -)