This is an old revision of the document!
Table of Contents
How to copy files \ directories \ filesystems via network.
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:
- New server (IP: 192.168.0.14)
- Old server (IP: 192.168.0.1)
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.
Copy Files / Directories
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:
- -r: recursive (copy all the content of
/etc
including its subdirectories) - -p: preserve file attributes (eg. file creation or modification times)
- -v: verbose output
In the example above we copy the /etc
directory located on a remote host (the old server: 192.168.0.1) to the /local_dir
on a local host ( “new” server).
Sadly, 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.
Copy whole filesystem
command
ssh root@192.168.0.1 "(cd / ; tar cf - . )" | (mkdir -p /From_Old_Server ; cd /From_Old_Server ; umask 000 ; tar xvf -)
help us transfer full filesystems without stuck and pain from “old” to “new” computer.