I created a brand new default Drupal 7 website and I added the following additional test files which match my exclude patterns and therefore be excluded from the archive dumps:
$ cd ~/Sites/example.com/public_html
Here is the exact alias record from ~/.drush/aliases.drushrc.php
$aliases['example.com'] = array(
'uri' => 'example.com',
'root' => '/Users/zachharkey/Sites/example.com/public_html',
'command-specific' => array (
'archive-dump' => array (
'tar-options' => '--exclude=directory1 --exclude=sites/all/modules --exclude=*.txt',
),
),
);
I added the following test files, which match the exclude rules and should be excluded from the archive:
├── directory1
│ └── test.txt
└── test.txt
1 directory, 2 files
I was originally running drush 6.2.0, so I used Homebrew to completely uninstall then reinstall drush and verified that I had been upgraded to 6.3.0.
$ brew info drush
drush: stable 6.3.0, HEAD
https://github.com/drush-ops/drush
/usr/local/Cellar/drush/6.3.0 (258 files, 2.5M) *
Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/drush.rb
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
And a quick double check:
$ drush --version
Drush Version : 6.3.0
Here is the full status of the bootstrapped Drupal site:
$ drush status
Drupal version : 7.31
Site URI : http://default
Database driver : mysql
Database username : root
Database name : example_db
Database : Connected
Drupal bootstrap : Successful
Drupal user : Anonymous
Default theme : bartik
Administration theme : seven
PHP executable : /Applications/MAMP/bin/php/php5.5.10/bin/php
PHP configuration : /Applications/MAMP/bin/php/php5.5.10/conf/php.ini /Users/zachharkey/.dotfiles/.drush/drush.ini
PHP OS : Darwin
Drush version : 6.3.0
Drush configuration :
Drush alias files : /Users/zachharkey/.drush/aliases.drushrc.php
Drupal root : /Users/zachharkey/Sites/example.com/public_html
Site path : sites/default
File directory path : sites/default/files
Temporary file directory path : /Applications/MAMP/tmp/php
Just to be extra sure, I printed out the full site-alias for the currently bootstrapped site to make sure it was using the same configs from my site alias in ~/.drush/aliases.drushrc.php
:
$ drush site-alias @self --full --with-optional
$aliases["example.com"] = array (
'root' => '/Users/zachharkey/Sites/example.com/public_html',
'uri' => 'example.com',
'#name' => 'example.com',
'path-aliases' =>
array (
'%drush' => '/usr/local/Cellar/drush/HEAD/libexec',
'%site' => 'sites/example.com/',
),
'command-specific' =>
array (
'archive-dump' =>
array (
'tar-options' => '--exclude=directory1 --exclude=sites/all/modules --exclude=*.txt',
),
),
'#file' => '/Users/zachharkey/.drush/aliases.drushrc.php',
);
I ran the archive-dump
command with all the --tar-options
specified inline as arguments:
$ drush archive-dump --tar-options='--exclude=directory1 --exclude=sites/all/modules --exclude=*.txt"
Success The test files are properly excluded from the archive. (So are all the other .txt files)
$ drush archive-dump -v --tar-options="--exclude=directory1 --exclude=sites/all/modules --exclude=*.txt"
Initialized Drupal 7.31 root directory at /Users/zachharkey/Sites/example.com/public_html [notice]
Initialized Drupal site default at sites/default [notice]
/Applications/MAMP/bin/php/php5.5.10/bin/php -d memory_limit="512M" /usr/local/Cellar/drush/HEAD/libexec/drush.php --php=/Applications/MAMP/bin/php/php5.5.10/bin/php --php-options='-d memory_limit="512M" ' [notice]
--backend=2 --verbose --root=/Users/zachharkey/Sites/example.com/public_html --uri=example.com sql-conf --all 2>&1
Executing: tar --exclude=directory1 --exclude=sites/all/modules --exclude=*.txt --exclude "public_html/sites" --dereference -cf /Users/zachharkey/drush-backups/archive-dump/20140815063622/example_db.20140815_063624.tar public_html
Executing: tar --exclude=directory1 --exclude=sites/all/modules --exclude=*.txt --dereference -rf /Users/zachharkey/drush-backups/archive-dump/20140815063622/example_db.20140815_063624.tar public_html/sites/all
Executing: tar --dereference -rf /Users/zachharkey/drush-backups/archive-dump/20140815063622/example_db.20140815_063624.tar public_html/sites/README.txt
Executing: tar --dereference -rf /Users/zachharkey/drush-backups/archive-dump/20140815063622/example_db.20140815_063624.tar public_html/sites/example.sites.php
Executing: mysql --defaults-extra-file=/private/tmp/drush_C1HAhn --database=example_db --host=localhost --silent < /private/tmp/drush_BznhT1
Calling system(mysqldump --defaults-extra-file=/private/tmp/drush_6vZlVs example_db --host=localhost --result-file /tmp/drush_tmp_1408084584_53edaa684f9d0/example_db.sql --no-autocommit --single-transaction --opt -Q );
Database dump saved to /tmp/drush_tmp_1408084584_53edaa684f9d0/example_db.sql [success]
Executing: tar --exclude=directory1 --exclude=sites/all/modules --exclude=*.txt --dereference -rf /Users/zachharkey/drush-backups/archive-dump/20140815063622/example_db.20140815_063624.tar example_db.sql
/Applications/MAMP/bin/php/php5.5.10/bin/php -d memory_limit="512M" /usr/local/Cellar/drush/HEAD/libexec/drush.php --php=/Applications/MAMP/bin/php/php5.5.10/bin/php --php-options='-d memory_limit="512M" ' [notice]
--backend=2 --verbose --root=/Users/zachharkey/Sites/example.com/public_html --uri=example.com core-status 2>&1
Executing: tar --exclude=directory1 --exclude=sites/all/modules --exclude=*.txt --dereference -rf /Users/zachharkey/drush-backups/archive-dump/20140815063622/example_db.20140815_063624.tar public_html/sites/default
Executing: tar --dereference -rf /Users/zachharkey/drush-backups/archive-dump/20140815063622/example_db.20140815_063624.tar MANIFEST.ini
Executing: tar -tf /Users/zachharkey/drush-backups/archive-dump/20140815063622/example_db.20140815_063624.tar public_html/sites/default/default.settings.php
Executing: gzip --no-name -f /Users/zachharkey/drush-backups/archive-dump/20140815063622/example_db.20140815_063624.tar
Archive saved to /Users/zachharkey/drush-backups/archive-dump/20140815063622/example_db.20140815_063624.tar.gz [ok]
/Users/zachharkey/drush-backups/archive-dump/20140815063622/example_db.20140815_063624.tar.gz
Command dispatch complete
$ drush archive-dump --tar-options="--exclude=directory1 --exclude=sites/all/modules --exclude=*.txt" -debug
Bootstrap to phase 0. [0 sec, 1.88 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.01 sec, 2 MB] [bootstrap]
Loading drushrc "/Users/zachharkey/.dotfiles/.drush/drushrc.php" into "home.drush" scope. [0.01 sec, 2 MB] [bootstrap]
Cache HIT cid: 6.3.0-commandfiles-0-849789827cf6a34b4dfab413b845be17 [0.01 sec, 2.02 MB] [debug]
DRUSH_BACKEND:{"type":"bootstrap","message":"Bootstrap to phase 0.","timestamp":1408090028.09,"memory":8189648,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"bootstrap","message":"Bootstrap to phase 2.","timestamp":1408090028.17,"memory":8193800,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"bootstrap","message":"Drush bootstrap phase : _drush_bootstrap_drupal_root()","timestamp":1408090028.17,"memory":8196536,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"notice","message":"Initialized Drupal 7.31 root directory at \/Users\/zachharkey\/Sites\/example.com\/public_html","timestamp":1408090028.19,"memory":9170384,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"bootstrap","message":"Drush bootstrap phase : _drush_bootstrap_drupal_site()","timestamp":1408090028.19,"memory":9180296,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"notice","message":"Initialized Drupal site default at sites\/default","timestamp":1408090028.19,"memory":9182064,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"debug","message":"Cache HIT cid: 6.3.0-install_profile-66ecfeb9791a023150773849f1550c5d","timestamp":1408090028.19,"memory":9185056,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"debug","message":"Cache HIT cid: 6.3.0-commandfiles-2-5ae707b49cab741d0deaf738a6ac8e5f","timestamp":1408090028.19,"memory":9187904,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"bootstrap","message":"Found command: archive-dump (commandfile=archive)","timestamp":1408090028.19,"memory":9184296,"error":null,"packet":"log"}
DRUSH_BACKEND:{"error":"DRUSH_UNKNOWN_OPTION","message":"Unknown options: --e, --g. See `drush help archive-dump` for available options. To suppress this error, add the option --strict=0.","packet":"set_error"}
DRUSH_BACKEND:{"type":"memory","message":"Peak memory usage was 11.18 MB","timestamp":1408090028.37,"memory":9194248,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"debug","message":"Cache HIT cid: 6.3.0-alias-path--83fe446c9d15e5f63b2201f0640c760e","timestamp":1408090028.37,"memory":9193584,"error":null,"packet":"log"}
DRUSH_BACKEND_OUTPUT_START>>>{"output":"","object":[],"error_status":1,"log":[{"type":"bootstrap","message":"Bootstrap to phase 0.","timestamp":1408090027.95,"memory":1971416,"error":null},{"type":"bootstrap","message":"Drush bootstrap phase : _drush_bootstrap_drush()","timestamp":1408090027.95,"memory":2092344,"error":null},{"type":"bootstrap","message":"Loading drushrc \"\/Users\/zachharkey\/.dotfiles\/.drush\/drushrc.php\" into \"home.drush\" scope.","timestamp":1408090027.95,"memory":2098088,"error":null},{"type":"debug","message":"Cache HIT cid: 6.3.0-commandfiles-0-849789827cf6a34b4dfab413b845be17","timestamp":1408090027.96,"memory":2117912,"error":null},{"type":"bootstrap","message":"Bootstrap to phase 0.","timestamp":1408090028.09,"memory":8189648,"error":null},{"type":"bootstrap","message":"Bootstrap to phase 2.","timestamp":1408090028.17,"memory":8193800,"error":null},{"type":"bootstrap","message":"Drush bootstrap phase : _drush_bootstrap_drupal_root()","timestamp":1408090028.17,"memory":8196536,"error":null},{"type":"notice","message":"Initialized Drupal 7.31 root directory at \/Users\/zachharkey\/Sites\/example.com\/public_html","timestamp":1408090028.19,"memory":9170384,"error":null},{"type":"bootstrap","message":"Drush bootstrap phase : _drush_bootstrap_drupal_site()","timestamp":1408090028.19,"memory":9180296,"error":null},{"type":"notice","message":"Initialized Drupal site default at sites\/default","timestamp":1408090028.19,"memory":9182064,"error":null},{"type":"debug","message":"Cache HIT cid: 6.3.0-install_profile-66ecfeb9791a023150773849f1550c5d","timestamp":1408090028.19,"memory":9185056,"error":null},{"type":"debug","message":"Cache HIT cid: 6.3.0-commandfiles-2-5ae707b49cab741d0deaf738a6ac8e5f","timestamp":1408090028.19,"memory":9187904,"error":null},{"type":"bootstrap","message":"Found command: archive-dump (commandfile=archive)","timestamp":1408090028.19,"memory":9184296,"error":null},{"type":"memory","message":"Peak memory usage was 11.18 MB","timestamp":1408090028.37,"memory":9194248,"error":null}],"error_log":{"DRUSH_UNKNOWN_OPTION":["Unknown options: --e, --g. See `drush help archive-dump` for available options. To suppress this error, add the option --strict=0."]},"self":{"root":"\/Users\/zachharkey\/Sites\/example.com\/public_html","uri":"example.com","path-aliases":{"%root":"\/Users\/zachharkey\/Sites\/example.com\/public_html"},"command-specific":{"archive-dump":{"tar-options":"--exclude=directory1 --exclude=sites\/all\/modules --exclude=*.txt"}},"#file":"\/Users\/zachharkey\/.drush\/aliases.drushrc.php"},"context":{"php":"\/Applications\/MAMP\/bin\/php\/php5.5.10\/bin\/php","php-options":"-d memory_limit=\"512M\" -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d magic_quotes_sybase=Off","tar-options":"--exclude=directory1 --exclude=sites\/all\/modules --exclude=*.txt","e":true,"g":true,"debug":true,"user":true,"backend":true}}<<<DRUSH_BACKEND_OUTPUT_END
Running the command without any arguments should default to using the command-specific
settings from the site alias in ~/.drush/aliases.drushrc.php
$ drush archive-dump
Archive saved to /Users/zachharkey/drush-backups/archive-dump/20140815080251/example_db.20140815_080253.tar.gz [ok]
Fail The test files are not properly excluded from the expanded archive.
$ drush archive-dump -v
Initialized Drupal 7.31 root directory at /Users/zachharkey/Sites/example.com/public_html [notice]
Initialized Drupal site default at sites/default [notice]
/Applications/MAMP/bin/php/php5.5.10/bin/php -d memory_limit="512M" -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d magic_quotes_sybase=Off /usr/local/Cellar/drush/6.3.0/libexec/drush.php [notice]
--php=/Applications/MAMP/bin/php/php5.5.10/bin/php --php-options='-d memory_limit="512M" -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d magic_quotes_sybase=Off' --backend=2 --verbose
--root=/Users/zachharkey/Sites/example.com/public_html --uri=example.com sql-conf --all 2>&1
Executing: tar --exclude "public_html/sites" --dereference -cf /Users/zachharkey/drush-backups/archive-dump/20140815075603/example_db.20140815_075604.tar public_html
Executing: tar --dereference -rf /Users/zachharkey/drush-backups/archive-dump/20140815075603/example_db.20140815_075604.tar public_html/sites/all
Executing: tar --dereference -rf /Users/zachharkey/drush-backups/archive-dump/20140815075603/example_db.20140815_075604.tar public_html/sites/README.txt
Executing: tar --dereference -rf /Users/zachharkey/drush-backups/archive-dump/20140815075603/example_db.20140815_075604.tar public_html/sites/example.sites.php
/Applications/MAMP/bin/php/php5.5.10/bin/php -d memory_limit="512M" -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d magic_quotes_sybase=Off /usr/local/Cellar/drush/6.3.0/libexec/drush.php [notice]
--php=/Applications/MAMP/bin/php/php5.5.10/bin/php --php-options='-d memory_limit="512M" -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d magic_quotes_sybase=Off' --backend=2
--root=/Users/zachharkey/Sites/example.com/public_html --uri=example.com sql-query 'SHOW TABLES' 2>&1
Executing: mysqldump --result-file /tmp/drush_tmp_1408089365_53edbd15359dd/example_db.sql --no-autocommit --single-transaction --opt -Q example_db --host=localhost --user=root --password='KxicXy0wX69Q@xUAjz5'
Executing: tar --dereference -rf /Users/zachharkey/drush-backups/archive-dump/20140815075603/example_db.20140815_075604.tar example_db.sql
/Applications/MAMP/bin/php/php5.5.10/bin/php -d memory_limit="512M" -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d magic_quotes_sybase=Off /usr/local/Cellar/drush/6.3.0/libexec/drush.php [notice]
--php=/Applications/MAMP/bin/php/php5.5.10/bin/php --php-options='-d memory_limit="512M" -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d magic_quotes_sybase=Off' --backend=2 --verbose
--root=/Users/zachharkey/Sites/example.com/public_html --uri=example.com core-status 2>&1
Executing: tar --dereference -rf /Users/zachharkey/drush-backups/archive-dump/20140815075603/example_db.20140815_075604.tar public_html/sites/default
Executing: tar --dereference -rf /Users/zachharkey/drush-backups/archive-dump/20140815075603/example_db.20140815_075604.tar MANIFEST.ini
Executing: tar -tf /Users/zachharkey/drush-backups/archive-dump/20140815075603/example_db.20140815_075604.tar public_html/sites/default/default.settings.php
Executing: gzip --no-name -f /Users/zachharkey/drush-backups/archive-dump/20140815075603/example_db.20140815_075604.tar
Archive saved to /Users/zachharkey/drush-backups/archive-dump/20140815075603/example_db.20140815_075604.tar.gz [ok]
/Users/zachharkey/drush-backups/archive-dump/20140815075603/example_db.20140815_075604.tar.gz
Command dispatch complete
$ drush archive-dump -debug
Bootstrap to phase 0. [0.01 sec, 1.88 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.01 sec, 1.99 MB] [bootstrap]
Loading drushrc "/Users/zachharkey/.dotfiles/.drush/drushrc.php" into "home.drush" scope. [0.01 sec, 2 MB] [bootstrap]
Cache HIT cid: 6.3.0-commandfiles-0-849789827cf6a34b4dfab413b845be17 [0.01 sec, 2.02 MB] [debug]
DRUSH_BACKEND:{"type":"bootstrap","message":"Bootstrap to phase 0.","timestamp":1408088193.88,"memory":8189008,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"bootstrap","message":"Bootstrap to phase 2.","timestamp":1408088193.97,"memory":8193160,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"bootstrap","message":"Drush bootstrap phase : _drush_bootstrap_drupal_root()","timestamp":1408088193.97,"memory":8195896,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"notice","message":"Initialized Drupal 7.31 root directory at \/Users\/zachharkey\/Sites\/example.com\/public_html","timestamp":1408088193.98,"memory":9169432,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"bootstrap","message":"Drush bootstrap phase : _drush_bootstrap_drupal_site()","timestamp":1408088193.98,"memory":9179352,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"notice","message":"Initialized Drupal site default at sites\/default","timestamp":1408088193.98,"memory":9181120,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"debug","message":"Cache HIT cid: 6.3.0-install_profile-66ecfeb9791a023150773849f1550c5d","timestamp":1408088193.98,"memory":9184112,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"debug","message":"Cache HIT cid: 6.3.0-commandfiles-2-5ae707b49cab741d0deaf738a6ac8e5f","timestamp":1408088193.99,"memory":9186960,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"bootstrap","message":"Found command: archive-dump (commandfile=archive)","timestamp":1408088193.99,"memory":9183352,"error":null,"packet":"log"}
DRUSH_BACKEND:{"error":"DRUSH_UNKNOWN_OPTION","message":"Unknown options: --e, --g. See `drush help archive-dump` for available options. To suppress this error, add the option --strict=0.","packet":"set_error"}
DRUSH_BACKEND:{"type":"memory","message":"Peak memory usage was 11.18 MB","timestamp":1408088194.17,"memory":9193216,"error":null,"packet":"log"}
DRUSH_BACKEND:{"type":"debug","message":"Cache HIT cid: 6.3.0-alias-path--83fe446c9d15e5f63b2201f0640c760e","timestamp":1408088194.18,"memory":9192552,"error":null,"packet":"log"}
DRUSH_BACKEND_OUTPUT_START>>>{"output":"","object":[],"error_status":1,"log":[{"type":"bootstrap","message":"Bootstrap to phase 0.","timestamp":1408088193.74,"memory":1970896,"error":null},{"type":"bootstrap","message":"Drush bootstrap phase : _drush_bootstrap_drush()","timestamp":1408088193.74,"memory":2091824,"error":null},{"type":"bootstrap","message":"Loading drushrc \"\/Users\/zachharkey\/.dotfiles\/.drush\/drushrc.php\" into \"home.drush\" scope.","timestamp":1408088193.74,"memory":2097568,"error":null},{"type":"debug","message":"Cache HIT cid: 6.3.0-commandfiles-0-849789827cf6a34b4dfab413b845be17","timestamp":1408088193.74,"memory":2117376,"error":null},{"type":"bootstrap","message":"Bootstrap to phase 0.","timestamp":1408088193.88,"memory":8189008,"error":null},{"type":"bootstrap","message":"Bootstrap to phase 2.","timestamp":1408088193.97,"memory":8193160,"error":null},{"type":"bootstrap","message":"Drush bootstrap phase : _drush_bootstrap_drupal_root()","timestamp":1408088193.97,"memory":8195896,"error":null},{"type":"notice","message":"Initialized Drupal 7.31 root directory at \/Users\/zachharkey\/Sites\/example.com\/public_html","timestamp":1408088193.98,"memory":9169432,"error":null},{"type":"bootstrap","message":"Drush bootstrap phase : _drush_bootstrap_drupal_site()","timestamp":1408088193.98,"memory":9179352,"error":null},{"type":"notice","message":"Initialized Drupal site default at sites\/default","timestamp":1408088193.98,"memory":9181120,"error":null},{"type":"debug","message":"Cache HIT cid: 6.3.0-install_profile-66ecfeb9791a023150773849f1550c5d","timestamp":1408088193.98,"memory":9184112,"error":null},{"type":"debug","message":"Cache HIT cid: 6.3.0-commandfiles-2-5ae707b49cab741d0deaf738a6ac8e5f","timestamp":1408088193.99,"memory":9186960,"error":null},{"type":"bootstrap","message":"Found command: archive-dump (commandfile=archive)","timestamp":1408088193.99,"memory":9183352,"error":null},{"type":"memory","message":"Peak memory usage was 11.18 MB","timestamp":1408088194.17,"memory":9193216,"error":null}],"error_log":{"DRUSH_UNKNOWN_OPTION":["Unknown options: --e, --g. See `drush help archive-dump` for available options. To suppress this error, add the option --strict=0."]},"self":{"root":"\/Users\/zachharkey\/Sites\/example.com\/public_html","uri":"example.com","path-aliases":{"%root":"\/Users\/zachharkey\/Sites\/example.com\/public_html"},"command-specific":{"archive-dump":{"tar-options":"--exclude=directory1 --exclude=sites\/all\/modules --exclude=*.txt"}},"#file":"\/Users\/zachharkey\/.drush\/aliases.drushrc.php"},"context":{"php":"\/Applications\/MAMP\/bin\/php\/php5.5.10\/bin\/php","php-options":"-d memory_limit=\"512M\" -d magic_quotes_gpc=Off -d magic_quotes_runtime=Off -d magic_quotes_sybase=Off","e":true,"g":true,"debug":true,"user":true,"backend":true}}<<<DRUSH_BACKEND_OUTPUT_END