2

I seem to be frequently encountering a situation when I compress files of a Drupal site as a tarball from a production server to the public_html folder of my local machine.

The permissions seem to get messed up and I usually end up with a filesystem not readable error and deleting a few files in the sites/default/files directory during the process of changing the permissions.

How can I preserve these permissions when the folder is compressed and copied to a new folder or is it an issue with the permissions of the destination folder?

1 Answer 1

3

I move sites as tarballs between servers fairly often when I can't deploy with rsync or git.

According to the man page:

-p, --preserve-permissions
extract information about file permissions (default for superuser)

is the proper option to use. However, this never works well for me.

Typically, I will just use normal tar options, and then run a script after the fact to fix things up.

The Securing file permissions and ownership article has a very good script. As that gets adjusted from time to time, I am not going to reproduce it here. It essentially does some find/chown/chmods on the tree to fix things up.

I would use this script as a starting point for your needs. One thing that it doesn't address is having the private:// filesystem outside of docroot, which I always use. I will also use 2775 as the permission for the public:// path, as well as a separate use for core/contrib and the site specific code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.