{"id":986,"date":"2020-04-06T20:46:51","date_gmt":"2020-04-06T20:46:51","guid":{"rendered":"https:\/\/jan.schnasse.org\/blog\/?p=986"},"modified":"2026-09-28T11:38:46","modified_gmt":"2026-09-28T09:38:46","slug":"unix-tools-introduced-today-rsync","status":"publish","type":"post","link":"https:\/\/jan.schnasse.org\/blog\/2020\/04\/06\/unix-tools-introduced-today-rsync\/","title":{"rendered":"Unix tools introduced. Today: rsync"},"content":{"rendered":"<p>rsync is a very cool tool that can be used to copy files between hosts or between directories on the same host. Like the term &#8217;sync&#8216; suggests the copy process can be controlled into great detail to modulate rsync&#8217;s behavior.\u00a0 Take a look at the available options under: <a href=\"https:\/\/linux.die.net\/man\/1\/rsync\">https:\/\/linux.die.net\/man\/1\/rsync<\/a><\/p>\n<p>This is my list of cool options.\u00a0 I start with the most basic usage. The following command can be used to copy, and later on sync two directories.<\/p>\n<div class=\"post-text\">\n<pre><code>rsync -avn \/source\/dir \/target\/dir  \n<\/code><\/pre>\n<p>The command &#8218;archives&#8216; file attributes (<code>-a<\/code>) and displays some status info (<code>-v<\/code>).<\/p>\n<p>In the given form, the command only does a dry-run (<code>-n<\/code>). To execute the command remove the <code>-n<\/code>.<\/p>\n<p>The command uses the short form of <code>--archive<\/code> (<code>-a<\/code>) which translates to (<code>-rlptgoD<\/code>).<\/p>\n<ul>\n<li><code>-r<\/code> &#8211; recursive copy<\/li>\n<li><code>-l<\/code> &#8211; copy symlinks as symlinks<\/li>\n<li><code>-p<\/code> &#8211; set target permissions to be the same as the source<\/li>\n<li><code>-t<\/code> &#8211; set target mtime to be the same as the source. Use this to support fast incremental updates based on mtime.<\/li>\n<li><code>-g<\/code> &#8211; set target group to be the same as the source<\/li>\n<li><code>-o<\/code> &#8211; set target owner to be the same as the source<\/li>\n<li><code>-D<\/code> &#8211; if remote user is superuser this recreates devices and other special files.<\/li>\n<\/ul>\n<h1>More cool options<\/h1>\n<h2>Move<\/h2>\n<p><code>--remove-source-files<\/code> This will remove copied files from source.<\/p>\n<h2>Update<\/h2>\n<p><code>--update<\/code> This forces rsync to skip any files which exist on the destination and have a modified time that is newer than the source file.<\/p>\n<h2>Delete<\/h2>\n<p><code>--delete<\/code> Delete files on target that do not exist in source tree.<\/p>\n<h2>Backup<\/h2>\n<p><code>--backup<\/code> Make a backup of modified or removed files on target.<\/p>\n<p><code>--backup-dir=date +%Y.%m.%d<\/code> Specify a backup dir on target.<\/p>\n<h2>What to copy?<\/h2>\n<p><code>--min-size=1<\/code> Do not copy empty files. This can be particularly interesting if you have corrupted files in the source.<\/p>\n<p><code>--max-size=100K<\/code> Copy only small files. Can be used to handle small and large files differently.<\/p>\n<p><code>--existing<\/code> Only override files that already exist on the target. Do not create new files on target.<\/p>\n<p><code>--ignore-existing<\/code> Only copy files that do not exist on target.<\/p>\n<p><code>--exclude-from<\/code> Define excludes in a file.<\/p>\n<h2>Scheduling, Bandwidth and Performance<\/h2>\n<p><code>--time-limit<\/code> Ends rsync after a certain time limit.<\/p>\n<p><code>--stop-at=y-m-dTh:m<\/code> Ends rsync at a specific time.<\/p>\n<p><code>--partial<\/code> Allows partial copies in case of interruptions.<\/p>\n<p><code>--bwlimit=100<\/code> Limits bandwidth Specify KBytes\/second. Good option if transfer of large files is required.<\/p>\n<h2>Output<\/h2>\n<ul>\n<li><code>-h<\/code> output numbers in a human-readable format.<\/li>\n<li><code>--progress<\/code> display progress.<\/li>\n<li><code>-i<\/code> log change info.<\/li>\n<li><code>--log-file=<\/code> define a log file.<\/li>\n<li><code>--quiet<\/code> no output.<\/li>\n<li>\u00a0-v Output status info. You can add more &#8218;v&#8216;.<\/li>\n<li>Forgot to log any progress info? Use the following command to see what rsync is about to do.\n<pre><code> ls -l \/proc\/$(pidof rsync)\/fd\/*<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/div>\n<div class=\"grid mb0 fw-wrap ai-start jc-end gs8 gsy\">\n<p>&nbsp;<\/p>\n<div class=\"grid--cell mr16\">\n<div class=\"post-menu\"><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>rsync is a very cool tool that can be used to copy files between hosts or between directories on the same host. Like the term &#8217;sync&#8216; suggests the copy process can be controlled into great detail to modulate rsync&#8217;s behavior.\u00a0 Take a look at the available options under: https:\/\/linux.die.net\/man\/1\/rsync This is my list of cool [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,4,17],"tags":[],"class_list":["post-986","post","type-post","status-publish","format-standard","hentry","category-admin","category-bookmarks","category-unixtools"],"_links":{"self":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/comments?post=986"}],"version-history":[{"count":1,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/986\/revisions"}],"predecessor-version":[{"id":4201,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/posts\/986\/revisions\/4201"}],"wp:attachment":[{"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/media?parent=986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/categories?post=986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jan.schnasse.org\/blog\/wp-json\/wp\/v2\/tags?post=986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}