Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

syq cp

Copy files, directories, and symlinks between local paths, SSH servers, and S3 buckets. For examples, start with Copy files.

syq cp --srcs-in project --to server --into backup --dry-run -v

Put the source options (--from, -C or --root, --src-fd, selectors, and --mapping) before --to and the placement option. In scripts, SYQ_CP_OPTIONS adds arguments; see environment variables.

syq cp [OPTIONS] SOURCE... [PLACEMENT]
syq cp [OPTIONS] --src-fd FD --as PATH
syq cp [OPTIONS] SOURCE --as-fd FD

Sources and filtering

Argument / optionMeaning
--src-fd <FD>Read raw bytes from an inherited local descriptor (0 for stdin), instead of a source path
--from <ENDPOINT>Source endpoint ([USER@]HOST[:PORT], receiving name (@NAME), or s3://BUCKET); omitted means local
-C, --cwd <DIR>Resolve relative source paths from DIR
--root <DIR>Resolve source paths inside DIR and refuse any that lead outside it
--src <PATH>Select a named source object (repeatable)
--srcs-in <DIR>Select a directory’s contents (repeatable)
--src-non-dir <PATH>Select a named non-directory source object, such as a symlink itself (repeatable)
--src-dir <DIR>Select a named source directory (repeatable)
--src-non-dirs <PATH>...Select several named non-directory source objects
--src-dirs <DIR>...Select several named source directories
--srcs <PATH>...Select several named source objects
--where <EXPR>Copy only the non-directory entries that match a source expression; directories are not filtered
--ignore <PATTERN>Skip paths matching a gitignore-style pattern (repeatable)
--ignore-from <FILE>Read gitignore-style patterns from FILE (repeatable; applied in command-line order with –ignore)
[PATH]...Named source objects (shorthand for –src)

Destination and mapping

Argument / optionMeaning
--as-fd <FD>Write raw bytes to an inherited local descriptor (1 for stdout), instead of a destination path
--to <ENDPOINT>Destination SSH endpoint, receiving name (@NAME), or s3://BUCKET; without a placement option, copy into its starting directory (–into .)
--into <DIR>Put selected names inside DIR, creating it if necessary
--into-new <DIR>Put selected names inside DIR, which must not exist
--into-existing <DIR>Put selected names inside an existing directory
--as <PATH>Copy one named source to exactly PATH; a symlink at PATH is not followed
--as-new <PATH>Like –as, but PATH must not exist
--as-existing <PATH>Like –as, but PATH must already exist
--mapping <FILE>Copy the entries of a local NDJSON mapping file (- reads stdin) instead of selecting sources; src paths are relative to -C and dst paths to the –into directory. Cannot be combined with –ignore or –ignore-from

Updates and deletion

Argument / optionMeaning
--if-exists <POLICY>How to handle existing destination files

Possible values:
- error-if-different: Reject detected content differences; trusts matching size and mtime unless –hash is set
- error: Report an error for every existing destination file
- keep: Leave existing entries and their metadata alone
- update: Update contents when they differ and apply requested metadata
- update-if-older: Keep newer destinations; otherwise update differing contents

[default: update]
--copy-if <EXPR>Update only entries satisfying a source/destination expression
--in-place <MODE>Write files directly at their final names, with no staging file; interruption can leave them incomplete

Possible values:
- new: Only files the copy creates; an existing file is still replaced through a staging file
- update: Also existing files that syq can update where they are, writing only what changed; others are replaced. Anyone who has such a file open can read its new contents, and an interruption leaves it partly updated
--pruneAfter copying, remove destination entries the source does not have, within the copied directories; ignored paths are kept
--prune-beforeLike –prune, but remove the extra entries before copying to free space; a later copy failure does not restore them
--max-delete <N>With –prune or –prune-before, refuse all removals if more than N are planned
Argument / optionMeaning
--followFollow symlinks in all the paths you give
--follow-srcFollow symlinks in the source paths you give
--follow-dstFollow symlinks in the destination paths you give
--copy-metadata <FEATURE>Match selected source metadata, including on unchanged files (repeatable/comma-separated)

Possible values:
- mtime: Match source modification times
- permissions: Preserve permission bits
- ownership: Preserve owner and group IDs
- specials: Copy device nodes and special files
- hardlinks: Preserve hard links between selected regular files
- acls: Preserve native Linux or macOS ACLs and permission bits
- xattrs: Preserve Linux or macOS extended attributes
- atimes: Preserve access times captured before reading
- crtimes: Preserve birth times; requires a macOS destination
- content-type: Content-Type (S3-to-S3 only)
- content-encoding: Content-Encoding (S3-to-S3 only)
- content-language: Content-Language (S3-to-S3 only)
- content-disposition: Content-Disposition (S3-to-S3 only)
- cache-control: Cache-Control (S3-to-S3 only)
- expires: Expires (S3-to-S3 only)
- website-redirect: Website redirect (S3-to-S3 only)
- user-metadata: User metadata, except syq-* keys (S3-to-S3 only)
- tags: The complete tag set (S3-to-S3 only)
- storage-class: Storage class (S3-to-S3 only)
--widen-dirs <MODE>Which directories you own may briefly get the owner permission the copy needs; each is restored afterwards

Possible values:
- none: Never change directory permissions
- rsync: Directories the copy includes, as rsync does, but not the directory it copies into
- all: Also the directory the copy goes into and the directories above it

[default: none]
--open-noatimeRequest reads without access-time updates; warn and continue if unavailable
--sparseTurn written zero ranges into sparse holes

Verification

Argument / optionMeaning
--hashHash existing source and destination files instead of trusting size and modification time
--hash-or-copyLike –hash, but compare only where the transfer strategy reuses blocks (by default, between different machines) and copy other files whole, even if identical
--integrity-checking <KEY=VALUE,...>Payload checks

Connections and remote execution

Argument / optionMeaning
--no-compressDisable transport compression
--receiver-max-entries <N>Between two servers, refuse a restricted copy that would change more than N destination entries
--receiver-max-bytes <SIZE>Between two servers, refuse a restricted copy that would write more than SIZE bytes of file data
--auth-from <auto|ssh|@NAME|HOST>Whose SSH access to use for servers (default: SYQ_AUTH_FROM, then the saved choice, then auto):
- auto: this machine’s own, else a receiving machine’s approval for a copy with one server
- ssh: only this machine’s own
- @NAME: access approved by that receiving machine; also authorizes S3 copies
- HOST: access approved by an SSH authorization provider, a server holding your SSH keys
--coordinate-at <WHERE>Choose which machine runs the copy

Possible values:
- auto: This machine, unless both endpoints are remote; then the source
- src: The source endpoint
- dst: The destination endpoint
- local: This machine, relaying the data through it

[default: auto]
--rsh <COMMAND>Remote shell command (default: ssh); when set, it controls SSH options and agent forwarding
--syq-path <PATH>Run the remote syq at PATH instead of syq’s automatically installed copy
--no-bootstrapRun the syq found in the remote $PATH instead of syq’s automatically installed copy
--no-tcp-encryptionSend TCP data without encryption or authentication; use only on trusted networks
--no-tcpSend file data through SSH rather than separate TCP data connections
--tcp-ports <LO-HI>Port range that remote machines listen on for TCP data connections

[default: 47600-47699]
--tcp-congestion <ALGO>Use this congestion-control algorithm for TCP data sockets (Linux only)
--detachReturn as soon as the copy starts on the server that runs it
--peer-auth <MODE>How the server running the copy logs in to the other server; –rsh takes over this choice

Possible values:
- restricted: Let the other server accept only this copy, through restricted copying (see syq receiver); forwards no agent
- broker: Let it use your agent for that host and user, with full access to that account
- own-credentials: Forward nothing; it must have its own credentials for the other server
- full-agent: Forward your whole SSH agent, as ssh -A does

[default: restricted]
--pscope <PATH>Use the scope that syq persist on --ephemeral created at PATH, with its own connections and settings

S3 connection settings

Argument / optionMeaning
--s3-endpoint <URL>S3 API endpoint URL (also AWS_ENDPOINT_URL_S3 or AWS_ENDPOINT_URL)
--s3-region <REGION>S3 signing region, used as given (otherwise syq asks AWS where the bucket is)
--s3-profile <NAME>AWS shared configuration/credentials profile
--s3-header <NAME: VALUE>Add a header before signing every S3 request (repeatable; S3-to-S3 metadata/tag overrides are refused)
--s3-retries <N>Retry each S3 request up to N times after a transient failure or throttling, 0..100 (default 10; 0 disables retries)
--s3-write-header <NAME: VALUE>Add a header to S3 requests that create or replace objects (repeatable; S3-to-S3 metadata/tag overrides are refused)
--s3-directory-markers <MODE>Which directories get 0-byte dir/ marker objects on an S3 destination

Possible values:
- all: Create 0-byte dir/ markers for every copied directory (preserves empty directories and directory metadata)
- empty: Create 0-byte dir/ markers only for copied directories with no selected entries beneath them (before –if-exists/–copy-if)
- none: Create no 0-byte dir/ markers

[default: all]

Performance and resource limits

Argument / optionMeaning
--performance-tuning <KEY=VALUE,...>Workers, request sizes, and copy methods
--transfer-strategy <STRATEGY>Choose whether filesystem copies reuse matching blocks of the destination file they replace (default: locality; mounted network filesystems count as local).

Possible values:
- whole-file: Copy selected files without comparing blocks in the final destination
- aligned-block: Reuse matching blocks at the same offsets in the corresponding destination file
- locality: Whole-file when source and destination are on the same machine, aligned-block when they are on different machines
--resource-limits <KEY=VALUE,...>Bandwidth and concurrency ceilings

Preview, progress, and results

Argument / optionMeaning
--results <FILE>Write the machine-readable NDJSON result stream to FILE (created fresh; an existing file is refused)
--results-fd <FD>Write the result stream to an inherited file descriptor the caller opened (e.g. --results-fd 3 3>run.ndjson); must be above 2
-n, --dry-runPreview without changing files; remote setup may still install syq, and requested results files are still written
-v, --verbose...List files with -v; show connection details with -vv
-q, --quietSuppress non-error messages
--progressShow progress even when stderr is not a terminal
--no-progressNever show the human progress display
--statsPrint transfer statistics at the end

Help and version

Argument / optionMeaning
-h, --helpShow common usage and options
-V, --versionPrint version
--help-allShow all options and details

Update policies

--if-exists decides what happens to destination files that already exist; see existing-file policies and, before retrying a failed copy, resuming a copy.

error-if-different compares the contents of a file whose time differs before rejecting it; between S3 buckets it compares metadata instead (see Copies between S3 buckets). A file rejected for its contents keeps its metadata too.

--in-place cannot be combined with --if-exists=keep or update-if-older, because a retry would then skip a file left incomplete. Even with --in-place, a new file that must not replace anything (--as-new, or a new file under --if-exists=error or error-if-different) is written under a temporary name first. S3 destinations do not support --in-place. See In-place writes.

Pruning

Before pruning, keep the source outside the destination and let other copies into it finish; otherwise pruning can delete files you want. Syq refuses to prune a destination that it can see contains the source, but different SSH aliases for one server, or shared storage, can hide the overlap. Pruning never removes ignored paths, partial files, or recovery entries.

Filename and type conflicts

On a case-insensitive destination, Report.txt and report.txt (or two Unicode spellings of one name) collide. Syq does not check for this, so one replaces the other or is reported as a conflict. Rename one source, or use a destination that can tell them apart.

Syq never replaces a directory with a non-directory or the reverse, even an empty one; move or remove the conflicting entry first.

Metadata details

When you copy metadata to another machine, check how it carries over. Setuid, setgid, and sticky bits are copied only with --copy-metadata=permissions. Ownership and ACL entries are copied as numeric IDs (UUIDs for macOS ACLs), not translated to account names, so on another host they apply to whichever account has that ID there.

By default, a new --into directory, and any missing directory above an --into or --as target, gets the mode mkdir would give it: 0777 limited by the umask on the destination.

ACLs and extended attributes

acls copies POSIX ACLs on Linux and native ACLs on macOS, and refuses to copy them between the two. On a Linux source, xattrs copies user.* attributes for a non-root user, and for root every namespace except system.*, including security.selinux and security.capability. Both remove destination entries the source lacks, and a failure to read or set them makes the copy fail.

How syq changes existing files and directories

When only an existing file’s metadata differs, syq changes the metadata in place if all of these hold:

  • syq can tell the file has no other names (hard links),
  • the file belongs to the account syq runs as, and
  • the change adds no set-ID bit and changes no security attribute.

Run as root, syq changes in place whatever the file’s owner could change, and replaces the file to give it another owner or group.

Otherwise syq rewrites the file as if its contents had changed. That takes as long as copying it, needs room for a second copy, gives the file a new inode number, and drops attributes the copy doesn’t select, such as ACLs. Access times are always set in place.

Syq can’t tell whether a file has other names on some filesystems, such as SMB, SSHFS and other FUSE filesystems, and on macOS anything but APFS and HFS+. There every metadata-only change rewrites the file, and --in-place=update replaces files instead of updating them.

A directory gets its copied permissions after its contents, so an interrupted copy can leave a new directory open only to its owner.

If a directory you own lacks the write or search permission a change needs, syq cp names it and the changes in it fail; --widen-dirs lets syq briefly add the missing owner permission and restore it afterwards, as syq rsync does by default. A restricted copy with --if-exists=keep is the exception: it does not widen the existing directories the copy includes, so the changes in them still fail.

File descriptors

Use a descriptor copy to connect syq to another program without a temporary file. It streams raw bytes through an inherited file descriptor, a named pipe, or a process substitution. --src-fd 0 reads standard input and --as-fd 1 writes standard output; Shell pipelines and file descriptors has examples. Process substitution and named pipes work as sources:

syq cp --src <(gzip -c data) --to server --as data.gz
syq cp incoming.fifo --into saved

Each descriptor copy takes one source, and input without a filename needs --as or --as-fd. The second example waits for a writer and saves its bytes as the regular file saved/incoming.fifo. Syq reads or writes from a descriptor’s current position and never truncates it. Progress and -v output go to standard error, so descriptor 2 cannot carry a payload.

Completion and failures

A named destination is replaced only after the transfer succeeds, but syq cannot tell whether the producer succeeded: if the producer fails partway, syq still saves the bytes it received. Check the producer’s status, for example with Bash’s set -o pipefail; Python managed streams do this for you. Likewise, check syq’s exit status before using what it wrote to an output descriptor, which can be incomplete after a failure.

A killed copy can leave a .FILENAME.syq-tmp.RANDOM file beside the destination; once no copy is writing there, remove it with syq clean-partials. Older versions named it .syq-stream-*; delete such a file yourself.

Skips and previews

--if-exists=keep skips an existing destination without reading input, so a shell producer can get SIGPIPE. An output descriptor always exists, so --as-fd with keep always skips; update-if-older is refused, and other --if-exists values do not apply. --dry-run reads no input, so it cannot check a payload hash or a pipe’s length. --results reports one stream_result record.

Transport and limits

Descriptor copies refuse options for file trees, such as --hash, --prune, --where, and --detach, and cannot use a receiving name (@NAME). An interrupted one starts over. Filesystem descriptor copies accept only the workers, request-size, and pipeline-depth tuning keys; for S3, see Descriptor copies.

Descriptor metadata

A file written through --as-fd gets ordinary write timestamps unless you add --copy-metadata=mtime, which sets the time of the whole file. --copy-metadata=permissions,ownership copies those attributes too. A pipe, socket, or device source has no metadata; a new named destination for one gets mode 0666, limited by the umask.