{"id":637,"date":"2012-07-10T16:45:15","date_gmt":"2012-07-10T08:45:15","guid":{"rendered":"http:\/\/rmohan.com\/?p=637"},"modified":"2012-07-10T16:45:33","modified_gmt":"2012-07-10T08:45:33","slug":"rsync","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=637","title":{"rendered":"rsync"},"content":{"rendered":"<h3>rsync examples from command line.<\/h3>\n<p>&nbsp;<\/p>\n<p>To copy all the files in \/home\/lokams\/* of remote host to local directory \/backup\/home\/lokams\/<br \/>\n# rsync -e ssh -avz &#8211;delete &#8211;exclude dir\/* &#8211;delete-excluded &#8211;stats user@remotehost:\/home\/lokams\/ \/backup\/home\/lokams\/<\/p>\n<p>To copy the directory \/home\/lokams of remote host to local directory \/backup\/home. Directory &#8220;lokams&#8221; will get created in \/backup\/home.<br \/>\n# rsync -e ssh -avz &#8211;delete &#8211;exclude-from=~\/.rsync\/excludeFile &#8211;delete-excluded &#8211;stats user@remotehost:\/home\/lokams \/backup\/home\/<\/p>\n<p>To ignore the permissions errors while copying to remote windows\/mac systems, use &#8220;-rlt&#8221; option.<br \/>\n# rsync -e ssh -avz &#8211;delete &#8211;exclude dir\/* &#8211;delete-excluded &#8211;stats -rlt user@remotehost:\/home\/lokams\/ \/backup\/home\/lokams\/<\/p>\n<p>rsync behaves differently if the source directory has a trailing slash. Study and learn the difference between the following two commands before moving on. Use the -n option to rsync when testing to preview what would happen.<\/p>\n<p>$ rsync -n -av \/tmp .<br \/>\n$ rsync -n -av \/tmp\/ .<\/p>\n<p><strong>More rsync examples:<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/strong><\/p>\n<p># rsync -crogpvltz -e ssh &#8211;exclude &#8220;bin&#8221; &#8211;exclude &#8220;ifany&#8221; &#8211;delete &#8211;delete-after &#8211;bwlimit 20 root@10.144.17.1:\/apps\/uae\/ \/apps\/uae &gt; \/apps\/uae\/logs\/sync.log<\/p>\n<p># rsync -avz -e ssh root@remotehost:\/backup\/reptest \/backtmp\/reptest\/<\/p>\n<p># rsync -avz -e ssh \/logstage\/archive\/DXBSEC\/NODE0000\/ db2inst1@10.20.202.236:\/db2\/archivelog\/security\/logstage\/retrieve\/DXBSEC\/NODE0000\/<\/p>\n<p># rsync -e ssh -avz &#8211;timeout=999 &#8211;delete &#8211;exclude dir-or-file-to-exclude &#8211;delete-excluded &#8211;stats -rlt user@remotehost:\/home\/lokams\/<\/p>\n<p><strong>rsync useful options:<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n<\/strong><br \/>\n-a, &#8211;archive archive mode, equivalent to -rlptgoD<br \/>\n-n, &#8211;dry-run show what would have been transferred ( Preview mode )<\/p>\n<p>-c &#8211; always checksum<br \/>\n-r &#8211; recursive into directories<br \/>\n-o &#8211; preserve owner<br \/>\n-g &#8211; preserve group<br \/>\n-p &#8211; preserve permissions<br \/>\n-t &#8211; preserve times<br \/>\n-v &#8211; verbose<br \/>\n-l &#8211; copy symlinks as symlinks<br \/>\n-z &#8211; compress file data<br \/>\n-P &#8211; show progress during transfer<br \/>\n-q &#8211; quite (decrease verbosity)<br \/>\n-e &#8211; specify the remote shell<br \/>\n-b &#8211; make backup<br \/>\n-R &#8211; Use relative path names<br \/>\n-u &#8211; skip files that are newer on the receiver<\/p>\n<p>&#8211;stats give some file-transfer stats<br \/>\n&#8211;timeout=TIME set I\/O timeout in seconds<\/p>\n<p>&#8211;backup-dir &#8211; make backups into this directory<br \/>\n&#8211;bwlimit=KBPS &#8211; limit I\/O bandwidth, KBytes per second<br \/>\n&#8211;delete &#8211; delete files that don&#8217;t exist on the sending side<br \/>\n&#8211;delete-after &#8211; receiver deletes after transferring, not before<br \/>\n&#8211;daemon run as an rsync daemon<br \/>\n&#8211;address=ADDRESS bind to the specified address<br \/>\n&#8211;exclude=PATTERN exclude files matching PATTERN<br \/>\n&#8211;exclude-from=FILE exclude patterns listed in FILE<br \/>\n&#8211;include=PATTERN don&#8217;t exclude files matching PATTERN<br \/>\n&#8211;include-from=FILE don&#8217;t exclude patterns listed in FILE<br \/>\n&#8211;min-size=SIZE don&#8217;t transfer any file smaller than SIZE<br \/>\n&#8211;max-size=SIZE don&#8217;t transfer any file larger than SIZE<\/p>\n<p># &#8211;numeric-ids:<br \/>\nTells rsync to not map user and group id numbers local user and group names<br \/>\n# &#8211;delete:<br \/>\nMakes server copy an exact copy of the source by removing any files that have been removed on the remote machine<\/p>\n","protected":false},"excerpt":{"rendered":"<p>rsync examples from command line. <\/p>\n<p>&nbsp;<\/p>\n<p>To copy all the files in \/home\/lokams\/* of remote host to local directory \/backup\/home\/lokams\/ # rsync -e ssh -avz &#8211;delete &#8211;exclude dir\/* &#8211;delete-excluded &#8211;stats user@remotehost:\/home\/lokams\/ \/backup\/home\/lokams\/<\/p>\n<p>To copy the directory \/home\/lokams of remote host to local directory \/backup\/home. Directory &#8220;lokams&#8221; will get created in \/backup\/home. # rsync -e ssh [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/637"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=637"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/637\/revisions"}],"predecessor-version":[{"id":639,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/637\/revisions\/639"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}