Explain rsync code

Paste rsync commands and Vibe explains what gets copied and what gets deleted: what -avh, -n and --delete do, and why one trailing slash changes where the files go.

backup.sh

Up to 1,500 characters (about 60 lines). Your code is sent to Unvibe and Anthropic to write the explanation. Don't paste keys or passwords. Common key formats are refused.

Vibe16 lines selected

Press Explain it for the sample, or paste your own code first.

What this rsync sample shows

-a, -v and -h
-a copies folders inside folders and keeps each file's times and permissions, -v lists every file it copies and -h writes sizes like 150.03K. The first real run listed package.json, src/index.html and src/logo.png. Run again with nothing changed, it listed no files at all: rsync skips a file whose size and time already match.
the trailing slash
~/projects/my-site/ with the slash means what's inside my-site, so package.json landed at /mnt/backup/my-site/package.json. The commented-out last line, run on its own without the slash, copied the folder itself and made /mnt/backup/my-site/my-site, a second full copy one level down. That line has no --exclude, so node_modules and server.log came along too.
-n dry run
-n printed the same file list as the real run and ended with (DRY RUN). It even printed created directory, but the backup folder was still empty afterwards. The read line then waits: with SRC pointed at an empty folder, the dry run listed 3 deleting lines, and pressing Enter without typing yes stopped the script with both backup entries still there.
--delete and --exclude
After src/index.html was deleted from the project, the next run printed deleting src/index.html and removed it from the backup. Without --delete, a file deleted from the project stayed in the backup. Excluded files are protected: a node_modules folder already in the backup survived --delete, and only --delete-excluded removed it.

Good to know

  • Run with rsync 3.5.0 on Linux, with /mnt/backup as a local folder and a small project of package.json, src/index.html, a 150 KB src/logo.png, node_modules and server.log. The rsync in macOS is Apple's own build, which includes openrsync, a separate program (github.com/apple-oss-distributions/rsync), so its messages and options can differ from these.
  • With a typo in the source path, my-sit/, rsync printed change_dir for that path, then failed: No such file or directory, exited with code 23 and deleted nothing.

Watch out: --delete makes the backup match the source, even when the source is wrong. With an empty folder as the source, a --delete run removed every file in the backup and exited with code 0, as if all went well. Check SRC before a --delete run, keep the dry run and the yes prompt, and keep a second copy that the mirror never deletes from.

Explain rsync code beside your editor

Unvibe is a free app for Mac and Windows. In the app there is no pasting: select code in any app and press Control+U (Ctrl+Alt+U on Windows).

Install on Mac

curl -fsSL https://unvibe.site/install.sh | bash

Paste into Terminal. Unvibe isn't notarized by Apple yet, so this is the smooth path.

Opening the .dmg the first time
  1. Open the .dmg and drag Unvibe to Applications.
  2. Open it once; macOS says it can't verify it. Click Done.
    macOS dialog: Unvibe Not Opened, with Done and Move to Trash
    Real screen, macOS 15
  3. System Settings › Privacy & Security › Open Anyway. Confirm, then enter your Mac password. The button shows for about an hour after you try to open Unvibe.
    macOS Privacy & Security, Security section: Unvibe was blocked to protect your Mac, with the Open Anyway button
    Real screen, macOS 15

The Terminal line checks the download against the published SHA-256 and Unvibe's self-signed signature before it installs anything. More help with the first open