---
tags:
  - macOS
  - Tahoe
  - ditto
  - terminal
  - backup
  - copying
title: Advanced Copying and Archiving with Ditto on macOS Tahoe
---

# Advanced Copying and Archiving with Ditto on macOS Tahoe

While the standard Unix `cp` command is available on macOS, Apple provides its own specialized tool called `ditto`. `ditto` is often preferred for backups and complex copy operations because it is designed to preserve macOS-specific metadata, resource forks, and permissions that standard Unix tools might discard.

## Why Use Ditto?

*   **Metadata Preservation**: It preserves resource forks, HFS+ metadata, and extended attributes (ACLs).
*   **Directory Merging**: Unlike `cp`, `ditto` merges source directories into the destination. If the destination folder exists, `ditto` adds new files to it and updates existing ones, rather than replacing the folder entirely.
*   **Archiving**: It can create and extract compressed archives (ZIP, CPIO).

## Basic Copying

The syntax is straightforward: `ditto [source] [destination]`.

```zsh
ditto SourceFolder DestinationFolder
```

If `DestinationFolder` does not exist, it is created. If it does exist, `ditto` merges the contents of `SourceFolder` into it.

## Verbose Mode

To see exactly what is being copied, use the `-V` flag.

```zsh
ditto -V ~/Projects/MyApp /Volumes/BackupDrive/MyApp
```

## Creating Archives (ZIP)

`ditto` is an excellent tool for creating `.zip` archives via the terminal because it strips out unnecessary macOS system files (like `__MACOSX` folders) when used correctly, or preserves them when needed.

To create a standard ZIP archive:

```zsh
ditto -c -k --sequesterRsrc --keepParent SourceFolder archive.zip
```

*   `-c`: Create an archive.
*   `-k`: Use PKZip format (standard .zip).
*   `--sequesterRsrc`: Preserve macOS metadata (resource forks) safely.
*   `--keepParent`: Includes the parent folder name inside the zip (so unzipping doesn't explode files everywhere).

## Extracting Archives

You can also use `ditto` to unzip files.

```zsh
ditto -x -k archive.zip /path/to/destination
```

*   `-x`: Extract.
*   `-k`: PKZip format.

## Copying with Ownership (Sudo)

When backing up user data or system files, you often want to preserve the original file ownership.

```zsh
sudo ditto -V /Users/john /Volumes/Backup/john
```

This ensures that files owned by "john" remain owned by "john" on the backup drive.

For more on general terminal usage, refer to Getting Started with macOS Tahoe.