diff --git a/README.md b/README.md index eee1bc6..8bfbb4f 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/unix/do-a-dry-run-of-an-rsync.md b/unix/do-a-dry-run-of-an-rsync.md new file mode 100644 index 0000000..a2833a0 --- /dev/null +++ b/unix/do-a-dry-run-of-an-rsync.md @@ -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)