Note -r is required for directories (recursive copy). -i prompts before overwriting. Without -i, cp silently overwrites the destination. Use -a to preserve permissions, timestamps, and symlinks.
Note -c creates, -z compresses with gzip, -j with bzip2, -J with xz. -f must be followed by the archive name. --exclude omits patterns. Always put -f last among the single-letter flags or use the long form to avoid mistakes.
Frequently asked questions
How does Bash & Linux handle backup file?
Bash & Linux covers this with 2 copy-ready snippets on this page. The "Copy Files & Directories" snippet in Bash & Linux uses `cp [options] source destination`.
Which command does the Bash & Linux example use?
The "Copy Files & Directories" snippet uses `cp [options] source destination`, from the Navigation & Files section of the Bash & Linux cheat sheet.
What other Bash & Linux snippets are shown for "backup file"?
Besides "Copy Files & Directories", this page also shows "Create a Tar Archive".
Is there anything to watch out for?
Yes. For "Copy Files & Directories": -r is required for directories (recursive copy). -i prompts before overwriting. Without -i, cp silently overwrites the destination. Use -a to preserve permissions, timestamps, and symlinks.