Problem/Motivation
I found that archive-dump does not work on windows (using windows installer: Drush-5.x-dev-2011-12-07-Installer-v1.0.9.msi).
I found that the problem is actually the tar util.
Being a linux command it does not expect colon characters (:) in the path and interprets them as a transport protocol (i think) so absolute paths like "C:/...." do not work because the ":" is misinterpreted.
[EDIT]: I found another issue the --exclude option will not work for me under windows. I tried all possible ways to pass the --exclude option a path to exclude but it won't work. All I could do was use a pattern without slashes, so:
tar ... --exclude "root/sites" will not work but
tar ... --exclude "sites" or tar ... --exclude sites WILL work
But I do not want to use just "sites" as a pattern because that would also exclude any other folders named "sites" (maybe in a contrib or custom module)
Proposed resolution
A simple workaround I found was the "--force-local" option that tar supports and that forces it to interpret the path as a local path.
Since this worked for me I patched the archive.drush.inc file and just added support for the --force-local option to archive-dump.
So if you use archive-dump with the --force-local option it will be automatically be used when executing the tar commands.
So this is how it works:
drush archive-dump default --destination=/backups/mysite.tar --force-local
[EDIT]: The (rather hackish, ugly) solution I came up with was to verify if drush_is_windows() is true and if it is I will execute
tar -f file --delete root/sites
Remaining tasks
This is just my proposal.
It needs review and it could very easily be adapted to automatically append the "--force-local" option to the tar commands if it is run on a windows machine by using the drush_is_windows() function provided by the drush api.
[EDIT]: I am not happy with the solution for the tar exclude issue. Please let me know if you know a more suited way to fix this issue.
Also, I did not have the time to test how this path affects the functionality of the script in a linux environment. If anyone has the time to test this before I come around to doing it please share your results.
I have attached a patch to this issue.
[EDIT]: I have added a second patch in comment 3
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | drush_archive-dump_windows-tar-fix_tar-exclude-fix.patch | 3.98 KB | DizzyC |
| drush_archive-dump_windows-tar_fix.patch | 3.7 KB | DizzyC |
Comments
Comment #1
DizzyC commentedA similar issue exists: http://drupal.org/node/1259780.
But it takes another approach, by using bsdtar for windows instead of tar.
Comment #2
moshe weitzman commentedComment #3
DizzyC commentedFound another issue with tar under windows.
The --exclude option does not work as it should.
As it is used in the archive-dump command it has no effect on windows.
I attached a patch to this comment that solves both problems with tar (for me):
- "Function not implemented" when used with absolute paths
- "--exclude" option being ignored
Please read the issue body for more detailed information.
Comment #4
petsagouris commented@DizzyC: I applied the patch manually to my local Drush installation and it works just fine now. The patch was done manually because your patch is not well formed, please see this the git workflow applies.
Comment #5
greg.1.anderson commentedI believe that we should require bsdtar for Drush on Windows, and close this as "Won't fix". The proposed solution here is messy.
Comment #6
greg.1.anderson commentedComment #7
DizzyC commentedComment #8
greg.1.anderson commentedThis issue was marked
closed (won't fix)because Drush has moved to Github.If desired, you may copy this bug to our Github project and then post a link here to the new issue. Please also change the status of this issue to
closed (duplicate).Please ask support questions on Drupal Answers.
Comment #8.0
greg.1.anderson commentedI have identified one more problem with the archive-dump script on windows.
The --exclude option for tar does not work.