[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

copy directory tree, mapping to new owners



Hi all,

The context of my question is that I'm creating (or updating) a test copy of a website. The files are owned by one of two owners, depending on whether they were written by the server (actually php-fpm).

To do that, I want all the permissions to remain the same, but the ownership should be changed according to a provided map. For example, if the old file was owned by 'mysite', the copy should be owned by 'mysite_test'. If the old file was owned by 'mysite-run' (the user php runs as), the copy should be owned by 'mysite_test-run' (if that has to be 'mysite-run_test' to make things easier, I can live with that).

Group ownership is or would be the same, but in fact it's simpler because both users are members of teh same group - all files are or should be group-owned by the same group (mysite, mapping to mysite_test).

Is there any pre-existing tool that will do this? Or will I need to write a perl script or similar?

What I've done in the past is use the same users for both production and testing, and do the copy by running rsync as the mysite user, but firstly I'd rather have more isolation between the two, secondly the mysite user might not be able to read all the mysite-run files, and thirdly the ownership of those (mysite-run) files gets changed, making it an imperfect copy.

Thanks in advance,
Richard


Reply to: