How Do I Backup a Directory in Unix?
Contents

In order to copy a directory on Linux, you have to execute the “cp” command with the “-R” option for recursive and specify the source and destination directories to be copied. As an example, let’s say that you want to copy the “/etc” directory into a backup folder named “/etc_backup”.

How do I backup a folder in Linux?

Linux cp –backup

If the file you want to copy already exists in the destination directory, you can backup your existing file with the use of this command. Syntax: cp –backup <filename> <destinationDirectory>

How do I backup a file in Unix?

2.1 Copying Files

  1. cp (copy) cp file1 file2 is the command which makes a copy of file1 in the current working directory and calls it file2. …
  2. Exercise 2a. …
  3. mv (move) …
  4. rm (remove), rmdir (remove directory) …
  5. Exercise 2b. …
  6. clear (clear screen) …
  7. cat (concatenate) …
  8. less.
James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest