{"id":79,"date":"2008-11-09T18:18:26","date_gmt":"2008-11-09T17:18:26","guid":{"rendered":"http:\/\/www.askthegerman.com\/?p=79"},"modified":"2023-02-13T07:37:14","modified_gmt":"2023-02-13T06:37:14","slug":"duplicate-a-directory-with-find-and-cpio","status":"publish","type":"post","link":"https:\/\/www.askthegerman.com\/?p=79","title":{"rendered":"Duplicate a directory with find and cpio"},"content":{"rendered":"<p><font face=\"Arial\">Sometimes we need to duplicate a directory with subfolders into a new location on the same server and we have to make sure that these directories are exactly the same.<\/font><\/p>\n<p><font face=\"Arial\">Normally &#8211; but not best &#8211; we use the <strong><font face=\"Courier\">cp -pr<\/font><\/strong> command.<br \/>\nThe result is that our softlinks aren&#8217;t links anymore and the timestamps of some directorys are not the same as they are in the source directory. To partially solve this, you can use <font face=\"Courier\">tar <\/font>to create an archive and untar it in the destination &#8211; the better way is a combination of <font face=\"Courier\">find <\/font>and <font face=\"Courier\">cpio<\/font>. You will be save to get all files and directories <em>with links<\/em>, <em>timestamps <\/em>and <em>rights <\/em>in destination like they are in the source location.<br \/>\n<\/font><\/p>\n<p><font face=\"Arial\">example:<\/font><\/p>\n<p><font face=\"Arial\"><strong>c<\/strong>hange to the <strong>d<\/strong>irectory you want to copy from and invoke the following command<br \/>\n<strong><font face=\"Courier\">find . -depth -print | cpio -pdmv <em>\/destination<\/em>\/ <\/font><\/strong><br \/>\n<\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes we need to duplicate a directory with subfolders into a new location on the same server and we have to make sure that these directories are exactly the same. Normally &#8211; but not best &#8211; we use the cp -pr command. The result is that our softlinks aren&#8217;t links anymore and the timestamps of [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,31,15],"tags":[97,96,95,100,101,98,77,263,99],"class_list":["post-79","post","type-post","status-publish","format-standard","hentry","category-operatingsystem","category-tipsntricks","category-unix","tag-cpio","tag-directory","tag-duplicate","tag-find","tag-softlinks","tag-symbolic-links","tag-tar","tag-unix","tag-untar"],"_links":{"self":[{"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/posts\/79","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=79"}],"version-history":[{"count":6,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/posts\/79\/revisions"}],"predecessor-version":[{"id":373,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=\/wp\/v2\/posts\/79\/revisions\/373"}],"wp:attachment":[{"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.askthegerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}