1

in my Linux machine under /var/Recording directory.

I have hundreds directories and each directory there are also directories and files include hard links and soft link .

I want to compress all directories under /var/Recording directory to create one compressed file.

With which command I can create the best compressed file? - tar or cpio (regarding I have hard links and softlink files).

second what the right syntax of the tar/cpio command?

  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1034
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1033
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1038
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1037
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1036
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1041
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1040
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1039
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1044
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1043
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1042
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1047
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1046
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1045
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1049
  drwxr-x--- 2 root root 4096 Nov 22 18:57 458ca4e8-0edf-4204-9f9b-9c3dc02953c5.1048
  .
  .
  .
  .
  .
bwDraco
  • 46,683
maihabunash
  • 489
  • 2
  • 6
  • 16

1 Answers1

0

I'm a fan of tar. It will preserve hardlinks and softlinks. The command you can use for your situation is as follows.

cd /var
tar cvzf ~/Recording.tgz Recording

That creates a gzipped file called Recording.tgz with verbose output of the directory Recording. Paths will be preserved. There are lots of options that go with tar that you can review in the man pages. To restore your files, change to the directory were you want to put them and run tar again using the following command.

tar xvzf ~/Recording.tgz

To see what the file has in it prior to untarring, simply type

tar tvzf ~/Recording.tgz
R Schultz
  • 3,101