0

I want to copy /var/lib with same permissions of all files and folders.

some articles says cp -rp /var/lib/ /var/libnew/

and some says use rsync -aX /var/lib /var/libnew/

explain please which one is better as most important thing in which All permissions should be same 100 percent.

Romeo Ninov
  • 5,263
  • 4
  • 20
  • 26
Noor
  • 21
  • 1
  • 1
  • 5

1 Answers1

1

Both articles are correct and does what you want.

I prefer using rsync -avh --progress <source>/ <destination> (in your case: rsync -avh --progress /var/lib/ /varlibnew) for the progress bar of the copying, you can also add -u if you want to update files in destination, if they are newer.

With rsync, mind that trailing / are of importance, if both source and destination have trailing /:s, then the destination goes one level deeper.