Export config from remote, no drush


Si Hobbs


In some situations you may find yourself lacking drush access to export config from a remote environment. The article presents a script alternative.

Sometimes you have config, such as webform or views, being changed in a remote environment. When you don't have a quick way to capture it, it can be frustrating for the developer.

Ideally, the best way to capture config will be something like drush @remote config-export, but this is not possible if you don't have ssh access to the remote environment. Another option is pulling down a database dump, importing the database and exporting the config locally. 

If these options are not available, or least not available in a timely way, then you might visit /admin/config/development/configuration/full/export in the Drupal admin. You can press Export, and download a tar.gz file, and place it locally. For the script below your user account will need access to this admin page.

Today we look at the last option as a script, without getting too technical about it. Basically we need to:

  • Log in with our Drupal password (not stored anywhere)
  • Save the session cookie
  • Load the config export page (your user needs access)
  • Save and extract the zip file in the config directory locally
  • ... Ready to commit in the Git repo

This script is as-is. If you use this script you should understand or modify it to suit your own circumstances. Although it's unlikely to do any damage that a git checkout config can't fix. Some notes:

  • Assumes config is in ./config/default relative to where the script is run from (eg the root of the repo).
  • Doesn't really do any error handling.
  • Assumes the login form is default at /user/login.
  • Hard-codes the DOMAIN setting which you'd need to edit.
  • Assumes your local config is committed and a git diff config will show new changes.
  • Tested on OSX, not sure if this would work on other platforms.

If you improve this script, please share!


echo "What is your website user name:"
read USER

echo "What is your website password:"
read -s PASS


# If your site is protected by shield.
#  --http-user somename \
#  --http-password somepass \

wget \
  --keep-session-cookies \
  --save-cookies /tmp/some-cookies.txt \
  --post-data ${POST} \
  --delete-after \

wget -O ./config/default/exported-config.tar.gz \
  --load-cookies /tmp/some-cookies.txt \

rm -Rf ./config/default/*.yml
tar xzf ./config/default/exported-config.tar.gz -C ./config/default
rm ./config/default/exported-config.tar.gz

git diff config

echo "Done. Check the output of 'git diff config' above and commit once you're happy."






Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.


  • Allowed HTML tags: <em> <strong> <cite> <blockquote cite> <ul type> <ol start type> <li> <dl> <dt> <dd> <p>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
  • Use [gist:#####] where ##### is your gist number to embed the gist
    You may also include a specific file within a multi-file gist with [gist:####:my_file].

Spread the word