-2

i want to copy all files (/var/www/html) from system A (debian) to system B (debian) without loosing all chown and chmod configurations. there are more then 200.000 files in the folder and many of them have special rule configurations. it is really hard to change all files by hand and i also didnt write an extern file to know which file has a special rule to write an c file to do that for me. has some admins experiences with that and some tips for me how to hande that in future correctly? br

1 Answers1

1

Use the tar command, it will preserve ownership data and access modes. You simply need to create an archive, copy it to the other computer, unpack it, and that's it.

It can store extended attributes, SELinux context and ACLs as well, however, you will have to explicitly enable these when packing and when unpacking as well.

For example, if you want to store ACLs and extended attributes, you have to use a command like this:

tar cf the_tar_file /var/www/html --acls --xattrs

And you will have to specify these switches on unpacking as well:

tar xf the_tar_file --acls --xattrs

In order for this to work well, the users must exist on the target computer, and they must have the same user ID. On extract, tar will assign the files to the corresponding user ID, no matter what, so if the user doesn't exist, the file will have an ownership of a nonexistent ID. If the user ID belong to someone else, they will have the extracted file.

Setting ACLs will fail if one of the users defined in the ACL doesn't exist, so in this case, the whole ACL will get skipped (even valid entries).

Lacek
  • 6,585
  • 22
  • 28