Why when I do a configuration export in Drupal 8 does the config.tar.gz in tmp not get copied to the sync folder?

by Rory   Last Updated July 30, 2018 08:07 AM

This happens when I use the UI and Drush cex. The config.tar.gz is created in the tmp folder but nothing is created in the sync folder that I created in sites/default.

I have searched for similar tickets here, on Drupal.org and searching in google! I find references to folder and file permissions (I have tried 777 on most) and references to a .htaccess file in the sites/default folder with specific content.

The content my .htaccess file in sites/default is:

# Deny all requests from Apache 2.4+.
<IfModule mod_authz_core.c>
  Require all denied
</IfModule>

# Deny all requests from Apache 2.0-2.2.
<IfModule !mod_authz_core.c>
  Deny from all
</IfModule>
# Turn off all options we don't need.
Options -Indexes -ExecCGI -Includes -MultiViews

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
    # Override the handler again if we're run later in the evaluation list.
    SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
  php_flag engine off
</IfModule>

I am using the DDEV environment to create docker containers on my local Ubuntu 10.04 VM (VirtualBox) on my Windows 10 PC. I use the DDEV default settings.php for Drupal 8. I then added the following lines:

// Config sync directory.
#$config_directories['sync']='sites/default';
$config_directories = array (
    CONFIG_SYNC_DIRECTORY => 'sites/default',
);

// Configure private file path
$settings['file_private_path']='sites/default/private';

// Configure trusted host patters to prevent HTTP HOST header attacks
$settings['trusted_host_patterns'] = [
    '^<projectname>\.ddev\.local$',
];

I have tried variations of the $config_directories definition including the commented out version. I also defined the sync directory to be 'sites/default/sync'. I have created the 'sites/default/sync' directory. I have tried deleting the config.tar.gz in the tmp directory which gives the log message 'The file tmp/config.tar.gz was not deleted because it does not exist.' and then creates the config.tar.gz file in the tmp directory.

I have tried find . -name *.tar.gz to search all the directories for any such files in case it has put it somewhere unexpected and no luck!

OK so for my versions:

Ubuntu 18.04, DDEV 0.18.0 (Nginx 1.14.0, PHP 7.1.16-1+0~20180405085551.16+jessie~1.gbp4937aa, Database 5.5.5-10.1.28-MariaDB ), Drupal 8.5.5. I have done these tests on a standard Drupal installation with the only additional module being Backup and Migrate 8.x-4.0. I have enabled a few of the core modules not enabled by the standard installation (e.g. Media).

There don't appear to be any messages in my latest Drupal error log for today (my most recent test of this bug).

Is there anything else I can supply that might help diagnose what I am doing wrong?

Thanks in advance for your help.

Rory



Answers 1


The best way to store configuration is to store it outside of Drupal root directory.

For example you will have next project structure:

enter image description here

Where:

  1. config/sync is a directory with your sync configuration.
  2. public_html is a directory with your Drupal 8.

In your setting.php just add this

$config_directories['sync'] = '../config/sync';

And export your active configuration using drush

drush cex

That's all. In config/sync directory you will a files list of all your configuration.

Alex Kuzava
Alex Kuzava
July 30, 2018 07:34 AM

Related Questions


Using Configuration API in drupal 8

Updated June 15, 2015 23:03 PM




Config folder in drupal8

Updated April 13, 2016 08:03 AM