{
  "id": 8132834,
  "title": "What `rsync -avz --delete` Actually Does",
  "url": "https://urgent.news/2026/09/18/what-rsync-avz-delete-actually-does",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-18T00:13:53.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/susumun/what-rsync-avz-delete-actually-does-3hnl"
  },
  "original_language": "en",
  "account": "The rsync command is a powerful tool for synchronizing files between locations. When used with the flags -avz --delete, it performs a recursive copy of files while preserving metadata like permissions and timestamps, compresses the data being transferred to save bandwidth, and optionally removes files from the destination that no longer exist in the source. This combination of flags is commonly used to mirror the contents of one directory to another.\n\nBreaking down the flags:\n\n- -a: Archive mode, which recursively copies files while preserving permissions, timestamps, symbolic links, and ownership. This is equivalent to several other flags combined: -r (recursive), -l (copy symlinks as symlinks), -p (preserve permissions), -t (preserve modification times), -g (preserve group ownership), -o (preserve owner), and -D (preserve device files and special files). A notable aspect of -a is the preservation of timestamps, which is crucial for rsync's change-detection mechanism to work correctly.\n\n- -v: Verbose mode, which prints the name of every file transferred, providing a detailed output of the synchronization process.\n\n- -z: Compresses the data being transferred, reducing the amount of bandwidth used during the synchronization process.\n\n- --delete: This flag is what allows rsync to mirror the destination directory to the source directory. It removes files from the destination that no longer exist in the source, ensuring that both directories match exactly. However, its scope is limited to the specific source and destination directories provided. If the destination path is not narrowly scoped, --delete can inadvertently remove files from sibling directories outside the intended scope.\n\nA practical example of using rsync with these flags for a theme deployment is provided. The command is carefully scoped to the specific theme directory, ensuring that --delete only removes files from the theme's directory and not from other themes or directories on the server. This careful scoping is essential to avoid unintended file deletions.\n\nThe -e flag is used to specify the connection method, in this case, SSH with a key file and a specific port. This is important for secure and unattended deployments. The trailing slash in the source path ensures that the contents of the theme directory are copied directly into the destination, rather than being nested one level deeper.\n\nIn summary, the rsync -avz --delete flags together create a powerful and safe tool for synchronizing directories. The key to using --delete safely is to carefully scope the destination path to ensure that only the intended files are removed.",
  "summary": "A lot of people paste rsync -avz --delete into a deploy script and move on without ever unpacking what each letter means. It works, so there's rarely a reason to stop and ask. But understanding what each flag actually instructs the command to do makes it much easier to reason about exactly how far --delete reaches, and why the other flags are there in the first place. This post breaks down the…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 2,
    "also_reported_by": [
      {
        "outlet": "Dev.to",
        "title": "What std::mem::forget Actually Does to Heap Allocations",
        "url": "https://urgent.news/2026/09/17/what-std-mem-forget-actually-does-to-heap-allocations",
        "published": "2026-09-17T15:37:00.000Z"
      }
    ]
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}