{"id":374,"date":"2013-12-03T12:24:04","date_gmt":"2013-12-03T18:24:04","guid":{"rendered":"http:\/\/www.marcblase.com\/blog\/?p=374"},"modified":"2025-09-10T10:41:42","modified_gmt":"2025-09-10T15:41:42","slug":"sorry-cp-im-gonna-be-spending-more-time-with-rsync-now","status":"publish","type":"post","link":"https:\/\/ma.rcbla.se\/blog\/2013\/12\/sorry-cp-im-gonna-be-spending-more-time-with-rsync-now\/","title":{"rendered":"Sorry &#8216;cp&#8217; I&#8217;m gonna be spending more time with &#8216;rsync&#8217; now"},"content":{"rendered":"<p>So just updated my dev machine and was transferring files back to it via <code>cp<\/code> which was taking a long time. I just wanted to know how far along the command had progressed via a percentage\/progress bar\/etc. so that I could get a cup of coffee, or make lunch &ndash; if it was gonna take a very long time. I know it&#8217;s possible to do this but not by using <code>cp<\/code> alone.<\/p>\n<p>So I found <code>rsync<\/code> after a little bit of googling. The part that I really like about it is the <code>--progress<\/code> option, which let&#8217;s you know via stdout how far along the command is.<\/p>\n<p>Here is a basic example:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nrsync --progress -a \/path\/to\/source \/path\/to\/destination\r\n<\/pre>\n<p>&#8211; This will copy a directory, show progress, and maintain ownership, permissions, modified via the <code>-a<\/code> option (Archive).<\/p>\n<p>or, over the network:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nrsync -zP \/path\/to\/source handle@domain.tld:\/path\/to\/destination\r\n<\/pre>\n<p>&#8211; This will copy source over the network connection specified, use compression, show progress and allow for continuing interrupted transfers.<\/p>\n<p>P.S. As a preemptive measure you could also run <code>du -sh<\/code> on dirs before copying to get an idea of how big they actually are.<\/p>\n<p>UPDATE:<\/p>\n<p>To change port use -e flag. Eg.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nrsync -rvz --progress -e &quot;ssh -p 2222&quot; \/src\/dir user@host:\/dest\/dir\r\n<\/pre>\n<p>-r = recursive<br \/>\n-v = verbose<br \/>\n-z = compress<br \/>\n&#8211;progress =  display progress in stdout<br \/>\n-e = use ssh and change port to specified after -p<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So just updated my dev machine and was transferring files back to it via cp which was taking a long time. I just wanted to know how far along the command had progressed via a percentage\/progress bar\/etc. so that I could get a cup of coffee, or make lunch &ndash; if it was gonna take [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51,3,34],"tags":[57,52],"class_list":["post-374","post","type-post","status-publish","format-standard","hentry","category-cli","category-discoveries","category-networking","tag-cli","tag-linux"],"_links":{"self":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/comments?post=374"}],"version-history":[{"count":9,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/374\/revisions"}],"predecessor-version":[{"id":1418,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/374\/revisions\/1418"}],"wp:attachment":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/media?parent=374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/categories?post=374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/tags?post=374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}