With the folder structure like so
/site_root /site_root/images /site_root/core /site_root/core/modules/images /site_root/libraries

When doing a drush archive dump backup, from the inside site_root (usually it's public_html but in this case it's another folder), I use
$ drush ard tar-options="--exclude=images" --destination=~/.backups/[date].tar.gz

That way the archive dump skips the /site_root/images folder and the ard is much smaller. Unfortunately for me pattern matching then causes all images folders throughout to be excluded due to recursivity. So I would lose

I know in linux you can make tar-options look at the folder structure by making the pattern relative, like so
$ drush ard tar-options="--exclude=./images"
But that is not working for me via drush ard tar-options.

I also tried the home folder shortcut '~' (which works a treat on drush ard destination) like so
$ drush ard tar-options="--exclude=~/site_root/images" --destination=~/.backups/[date].tar.gz
But, for some reason, that does not work like it does on the –-destination switch.

What is the best way to limit the drush tar-options="exclude switch to either no-recursive or pattern match looking at relative path to working directory?

1 Answer 1


I've found that you can use the current working directory, as the starting point, to force relative urls. It was a matter of getting the syntax correct.

For example if you have your site root in public_html, and you are in that location cd ~/public_html, you can use drush:

[user public_html]$ drush ard tar-options="--exclude=public_html/images" --destination=~/.backups/[date].tar.gz

The key is to navigate to that starting point root folder first.

For example, if your site root was in a subdirectory subdirectory/siteone,
go to that location first cd ~/subdirectory/siteone
and then use drush:

[user siteone]$ drush ard tar-options="--exclude= siteone/images" --destination=~/.backups/[date].tar.gz

Your Answer

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

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