====== 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 ''/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 [[http://www.linuxquestions.org/questions/slackware-14/copy-whole-filesystem-via-scp-4175449321/#post4887869|provided]] by Patrick Volkerding. ====== Copy whole filesystem hierarchy ====== 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 -) ====== Sources ====== * Originally written by [[wiki:user:wisedraco|John Ciemgals]] 2013/02/10 03:51 \\ * With help from Patrick Volkerding {{tag>howtos copy ssh}}