Skip to content

Instantly share code, notes, and snippets.

@magnetikonline
Last active September 26, 2022 00:13
Show Gist options
  • Save magnetikonline/cbe35babeda92d4562a9 to your computer and use it in GitHub Desktop.
Save magnetikonline/cbe35babeda92d4562a9 to your computer and use it in GitHub Desktop.
Rsync delete orphan files from target only - no copy.

Rsync delete orphan files from target only - no copy

Calling rsync in the following way, using --existing, --ignore-existing and --delete allows the following:

  • Files at target that do not exist at source will be deleted.
  • Skipping all file copy operations from source to target.
$ rsync \
    --delete \
    --existing \
    --ignore-existing \
    --itemize-changes \
    --progress \
    --recursive \
      /path/to/source/ /path/to/target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment