Skip to content

Commit

Permalink
Rsync for making copies (command line)
Browse files Browse the repository at this point in the history
  • Loading branch information
verityj committed Jun 29, 2023
1 parent d6bcf18 commit f745e3c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions _posts/2023-06-09-rsync.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
layout: post
title: Rsync for making copies (command line)
date: 2023-06-09
last_modified_date: 2023-06-29
---

There are so many uses and options with rsync, it's mind-boggling. After some searching and manual reading, I arrived at a command that I use.
Expand All @@ -10,8 +11,9 @@ So many times I want to keep an extra copy of some important files on a couple o

```
rsync -avhWxS --no-compress --progress --info=progress2 <input file> <output directory>
# additional option that is sometimes needed:
# --delete-after
# rsync version 3.2.7 protocol version 31
# additional option that is sometimes needed:
# --delete-after
```

Options used:
Expand All @@ -21,6 +23,8 @@ Options used:
* `-W` copy files whole
* `-x` don't cross filesystem boundaries
* `-S` turn sequences of nulls into sparse blocks
* `--no-compress` no need for compression for local transfers
* `--progress --info=progress2` shows copy progress - may need an update from the old standard rsync version
* _the danger option:_ `--delete-after` delete extraneous files from the destination after the transfer of the new files (not during)

The above command became two aliases in my `~/.zshrc` file (or your shell file):
Expand All @@ -29,10 +33,15 @@ alias rsync-my="rsync -avhWxS --no-compress --progress --info=progress2"
alias rsync-my-delete="rsync -avhWxS --no-compress --progress --info=progress2 --delete-after"
```

Currently, Mac OS 13 ships with a _very old version 2_ of rsync. To get the beautiful copy progress for each file, I decided to upgrade rsync to the latest version 3 at the time. Instructions on rsync installation are on the [main rsync site]. There is one other major benefit for upgrading from version 2: [improved memory usage].

**Note**: this command is finicky with slashes at the end of source and destination directories to make sure to test it out with no deleting to see where the source files (or directories) are being sent. A `"control - c"` shortcut can exit the command if the files are not being put where you intended. Then, remove or add the "/" after the destination folder if the copy is one directory level off. I admit, with rsync, that has happened to me and so I learned.

### Say Hi!

<span class="nocomment">
<script src="https://nocomment.fiatjaf.com/embed.js" id="nocomment" data-owner="npub1vy40z9dxr943vkz6xp54elflf7hxcly46q2qwcpvzfy47qq3syxqqchgk3" data-custom-base="note1xskj4e3krta648m5tmzfga2hth52p8st2f292d0kyvxf5mn9vftqxlxc93"></script>
</span>

[main rsync site]: https://rsync.samba.org
[improved memory usage]: https://rsync.samba.org/FAQ.html#4

0 comments on commit f745e3c

Please sign in to comment.