[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
howtos:general_admin:files_filesystem_copying_over_network [2013/02/10 12:12 (UTC)] – created wisedracohowtos:general_admin:files_filesystem_copying_over_network [2013/02/10 17:00 (UTC)] (current) – [Copy Files / Directories] sycamorex
Line 1: Line 1:
 <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). --> <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). -->
 ====== How to copy files \ directories  \ filesystems via network. ====== ====== How to copy files \ directories  \ filesystems via network. ======
-That small article give a view of content copying task via network+The article describes ways of copying content over network. 
-I want do this on my homeserver upgrade, copy all info from working "old" server, to "new" server partition, for can make access a data and config files, for bring "new" server in state it looks be similar of "old" one, before switch "old" off, and set "new" instead it. +
-In examples, i work from "new" server CLI, it has IP 192.168.0.14 +
-"Old" server has IP 192.168.0.1, both in in one subnet.+
  
-====== Files \ single folder copying ====== +When upgrading home server, I copy all the data from the old server to a new system. In the examples belowI work from the new server and both servers are on the same subnet
- If you need a copy of standalone files or foldersyou can use an scp util+  * New server (IP: 192.168.0.14) 
-''scp -r -v -p root@192.168.0.1:/etc /From_Old_Server'' +  * Old server (IP: 192.168.0.1) 
-There -r key do recursively, i e copy all data in etc folder and its subfolders +
- -p key preserve file attributes, like a creation, modification times +
- -v gives us verbose output. +
- in there example we copy "etc" folder from 192.168.0.1 computer ( actually, "Old" server), to folder /From_Old_Server in local computer ( "new" server).+
  
-Sadly, but that command scp cannot copy whole sustem disk, contains /proc, /dev and even /Lost+Found catalog, who is it in extX filesystem partition - at that places scp stuck and stops.+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.
  
-Thanks to Patrick, "Volkerdi" gives us workaround for that situation: 
  
-====== Copy whole filesystem ====== 
  
-command +====== Copy Files / Directories ====== 
 +If you need to copy single files or directories, you can use the ''scp'' command:\\ 
  
-''ssh root@192.168.0.1 "(cd / ; tar cf - . )" | (mkdir -p /From_Old_Server ; cd /From_Old_Server ; umask 000 ; tar xvf -)''+<code> 
 +scp -r -v -p root@192.168.0.1:/etc /local_dir 
 +</code> 
 + 
 +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:  
 +<code bash> 
 +ssh root@192.168.0.1 "(cd / ; tar cf - . )" | (mkdir -p /local_dir ; cd /local_dir ; umask 000 ; tar xvf -) 
 +</code>
  
-help us transfer full filesystems without stuck and pain from "old" to "new" computer. 
  
  
Line 36: Line 45:
 <!-- * Originally written by [[wiki:user:xxx | User X]] --> <!-- * Originally written by [[wiki:user:xxx | User X]] -->
 <!-- * Contributions by [[wiki:user:yyy | User Y]] --> <!-- * Contributions by [[wiki:user:yyy | User Y]] -->
- * Originally written by[[wiki:user:wisedraco|John Ciemgals]] 2013/02/10 03:51 +  * Originally written by [[wiki:user:wisedraco|John Ciemgals]] 2013/02/10 03:51 \\ 
- * With help from Patrick Volkerding+  * With help from Patrick Volkerding
  
 <!-- Please do not modify anything below, except adding new tags.--> <!-- Please do not modify anything below, except adding new tags.-->
 <!-- You must remove the tag-word "template" below before saving your new page --> <!-- You must remove the tag-word "template" below before saving your new page -->
-{{tag>howtos template}}+{{tag>howtos copy ssh}}
 howtos:general_admin:files_filesystem_copying_over_network ()