Copy with cp -a to preserve everything (archive mode)
Archive copy files and directories keeping ownership, permissions, symlinks and timestamps intact on Linux.
01Command
$ cp -a /var/www/site /backup/site02What it does
Plain cp drops ownership and resets timestamps because it copies content, not metadata. The -a (archive) flag is shorthand for -dR --preserve=all: it recurses, never dereferences symlinks, and keeps every attribute that the running user is allowed to preserve. It is the standard way to back up or migrate a directory tree, and rsync -a mirrors the same semantics.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- cp(1) — Arch Linux manualEvidence: -a, --archive: same as -dR --preserve=all, preserving links, mode, ownership and timestamps
- cp(1P) — POSIX manual pageEvidence: POSIX documents the -a equivalent behaviors of preserve/duplicate/recurse used by cp -a
Last verified: 2026-09-17 · Category: Files & Folders
06Related solutions
rsync copies over SSH, skips unchanged files, resumes interrupted transfers, and preserves permissions and timestamps.
chattr sets filesystem attributes that override normal permissions — +i makes a file unmodifiable and undeletable, even by root.