1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-02 22:58:01 +00:00

Add Do A Dry Run Of An rsync as a unix til

This commit is contained in:
jbranchaud
2021-03-10 15:43:34 -06:00
parent 66a8dbb2dc
commit 8ffa0c3f3f
2 changed files with 42 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
_1079 TILs and counting..._
_1080 TILs and counting..._
---
@@ -1009,6 +1009,7 @@ _1079 TILs and counting..._
- [Display All The Terminal Colors](unix/display-all-the-terminal-colors.md)
- [Display Free Disk Space](unix/display-free-disk-space.md)
- [Display The Contents Of A Directory As A Tree](unix/display-the-contents-of-a-directory-as-a-tree.md)
- [Do A Dry Run Of An rsync](unix/do-a-dry-run-of-an-rsync.md)
- [Do Not Overwrite Existing Files](unix/do-not-overwrite-existing-files.md)
- [Enable Multi-Select Of Results With fzf](unix/enable-multi-select-of-results-with-fzf.md)
- [Exclude A Directory With Find](unix/exclude-a-directory-with-find.md)

View File

@@ -0,0 +1,40 @@
# Do A Dry Run Of An rsync
The `rsync` command, especially when running recursively (with the `-a` flag),
will create and update a bunch of directories and files. Because of that, you
may want to do a _dry run_ of an `rsync` command to make sure it is touching
the intended files.
The `--dry-run` flag (or the `-n` flag for short) will prepare a
synchronization of one directory to another. You can use this flag to be sure
that the source and target files and directories are correct.
The `-n` (or `--dry-run`) flag on its own won't _show_ what is going to get
synced. To get that information, you need to combine it with the `-v` (verbose)
flag.
```bash
$ rsync -anv til-temp/ til-content
building file list ... done
./
LICENSE
...
sent 909 bytes received 296 bytes 2410.00 bytes/sec
total size is 1058 speedup is 0.88
```
That will show everything that is going to be synced from `til-temp/`
recursively to `til-content`.
Doing a dry run is a great way to make sure you have the patterns for
`--exclude` flags correct, before actually syncing anything.
```bash
$ rsync -anv --exclude='./*.md' --exclude='.*' til-temp/ til-content
```
That excludes top-level markdown files and all dotfiles and dot-directories.
[source](https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories)