Ran drush pm update and it correctly found the modules that needed updating, but blew up when attempting to process the updates:

Updates will be made to the following projects:
Chaos tool suite [ctools-6.x-1.0-alpha3], Devel [devel-6.x-1.15], Panels [panels
-6.x-3.0-alpha3]

Note: Updated modules can potentially break your site. It's not recommended to update production sites without prior testing.
Note: If you have made any modifications to any file that belongs to one of these projects, you will have to migrate those modifications after updating.
Do you really want to continue? (y/n): y

drush: Failed to backup project directory DRUSH_DRUPAL_ROOT/sites/all/modules/ctools to DRUSH_DRUPAL_ROOT/backup/modules/20090331103753/ctools
PHP Warning:  mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323

Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323
PHP Warning:  mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323

Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323
PHP Warning:  mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323

Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323
PHP Warning:  mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323

Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323
PHP Warning:  mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323

Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323
PHP Warning:  mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323

Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323
PHP Warning:  mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323

Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 323
PHP Warning:  mysqli_query(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 108

Warning: mysqli_query(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 108
PHP Warning:  mysqli_errno(): Couldn't fetch mysqli in /var/www/html/example.com/html/includes/database.mysqli.inc on line 122

Replaced the actual domain name with example.com for security reasons. The group of PHP warnings was repeated six times before it exited back to the command prompt.

Comments

greg.1.anderson’s picture

Project: Drush extras » Drush
Version: 6.x-2.0-alpha1 »
Status: Active » Fixed

pm-update moved to Drush project. Presumed fixed; please-re-open if problems still persist.

izkreny’s picture

Title: drush pm update failes with tons of mysqli errors » drush pm-update failed using --backup-dir
Version: » All-versions-3.0-rc2
Status: Fixed » Active
Issue tags: +backup

Hello.

I tried to update diff module with this command: drush up diff --backup-dir=/home/users/mm/backup/ktest -d

This is output (I stripped-down and replaced sensitive data):

Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.03 sec, 2.67 MB]	[bootstrap]
Initialized Drupal 6.16 root directory at /www/sites/ktest.example.com [0.04 sec, 3.42 MB]	[notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.05 sec, 3.46 MB]	[bootstrap]
Initialized Drupal site default at sites/default [0.07 sec, 3.56 MB]	[notice]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.07 sec, 3.58 MB]	[bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [0.08 sec, 3.6 MB]	[bootstrap]
Successfully connected to the Drupal database. [0.08 sec, 3.6 MB]	[bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [0.09 sec, 3.82 MB]	[bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_login() [0.26 sec, 17.45 MB]	[bootstrap]
Found command: pm-update (commandfile=pm) [0.27 sec, 17.74 MB]	[bootstrap]
Including /home/users/mm/opt/drush/commands/pm/updatecode.pm.inc [0.27 sec, 17.74 MB]	[bootstrap]
Including version specific file : /home/users/mm/opt/drush/commands/pm/update_info/drupal_6.inc [0.27 sec, 17.9 MB]	[notice]
Refreshing update status information ...
Including version specific file : /home/users/mm/opt/drush/commands/core/drupal/environment_6.inc [36.33 sec, 19.72 MB]	[notice]
WD update: Attempted to fetch information about all available new releases and updates. [36.33 sec, 19.75 MB]	[notice]
Done.
Update information last refreshed: 4.4.2010 - 19:58

Update status information on all installed and enabled Drupal projects:
 Name                            Installed version  Proposed version  Status                    
 [...]
 Diff                            6.x-2.1-alpha2     6.x-2.1-alpha3    Update available          
 [...]

Including non-version specific file : /home/users/mm/opt/drush/commands/pm/package_handler/wget.inc [36.37 sec, 19.6 MB]	[notice]
Code updates will be made to the following projects:
Diff [diff-6.x-2.1-alpha3]

Note: Updated projects can potentially break your site. It is NOT recommended to update production sites without prior testing.
Note: A backup of your package will be stored to backups directory if it is not managed by a supported version control system.
Note: If you have made any modifications to any file that belongs to one of these projects, you will have to migrate those modifications after updating.
Do you really want to continue? (y/n): y
Starting to update Diff code at sites/all/modules/diff... [68.93 sec, 19.62 MB]	[notice]
Executing: svn info '/www/sites/ktest.example.com/sites/all/modules/diff' [68.94 sec, 19.62 MB]	[notice]
  svn: '/www/sites/ktest.example.com/sites/all/modules/diff' is not a working copy
Including non-version specific file : /home/users/mm/opt/drush/commands/pm/version_control/backup.inc [68.95 sec, 19.63 MB]	[notice]
Calling mkdir(/home/users/mm/backup/ktest, 511)
Calling mkdir(/home/users/mm/backup/ktest/modules, 511)
Calling mkdir(/home/users/mm/backup/ktest/modules/20100404205750, 511)
Calling rename(/www/sites/ktest.example.com/sites/all/modules/diff, /home/users/mm/backup/ktest/modules/20100404205750/diff)
Including version specific file : /home/users/mm/opt/drush/commands/core/drupal/environment_6.inc [68.95 sec, 19.65 MB]	[notice]
WD php: rename(/www/sites/ktest.example.com/sites/all/modules/diff,/home/users/mm/backup/ktest/modules/20100404205750/diff): Is a directory in /home/users/mm/opt/drush/includes/drush.inc on line 523. [68.95 sec, 19.64 MB]	[error]
Failed to backup project directory /www/sites/ktest.example.com/sites/all/modules/diff to /home/users/mm/backup/ktest/modules/20100404205750/diff [68.95 sec, 19.64 MB]	[error]
rename(/www/sites/ktest.example.com/sites/all/modules/diff,/home/users/mm/backup/ktest/modules/20100404205750/diff): Is a directory in /home/users/mm/opt/drush/includes/drush.inc on line 523. [68.95 sec, 18.89 MB]	[warning]
An error occurred at function : drush_pm_updatecode [68.95 sec, 18.89 MB]	[error]
Including version specific file : /home/users/mm/opt/drush/commands/core/drupal/environment_6.inc [68.95 sec, 18.9 MB]	[notice]
WD php: array_merge(): Argument #2 is not an array in /home/users/mm/opt/drush/commands/pm/updatecode.pm.inc on line 210. [68.95 sec, 18.9 MB]	[error]
array_merge(): Argument #2 is not an array in /home/users/mm/opt/drush/commands/pm/updatecode.pm.inc on line 210. [68.95 sec, 18.89 MB]	[warning]
Changes for drush_pm_updatecode module have been rolled back. [68.95 sec, 18.89 MB]	[rollback]
An error occurred at function : drush_pm_update [68.95 sec, 18.88 MB]	[error]
Command dispatch complete [68.95 sec, 18.88 MB]	[notice]
 Timer  Cum (sec)  Count  Avg (msec) 
 page   68.882     1      68881.67   
Peak memory usage was 20.86 MB [68.95 sec, 18.88 MB]	[memory]

If I just run drush up diff module is upgraded without problems.

Version of PHP:

PHP 5.2.0-8+etch16 (cli) (built: Nov 24 2009 11:14:47) 
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies

and /home/users/mm/backup/ktest folder have 2777 permissions..

Please let me know if maybe I need to open new issue or more data is needed..

greg.1.anderson’s picture

pm-updatecode works for me if the directory specified by --backup-dir is on the same volume as the project being updated. If I specify a --backup-dir that is on a different volume, then I get:

WD php: rename(): The first argument to copy() function cannot be a directory in            [error]
/home/ga/local/drush/includes/drush.inc on line 523.
WD php:                                                                                     [error]
rename(/srv/www/dev.greenknowe.org/sites/all/modules/pathauto,/data/archive/drupal/modules/20100404203602/pathauto):
Success in /home/ga/local/drush/includes/drush.inc on line 523.
Failed to backup project directory /srv/www/dev.greenknowe.org/sites/all/modules/pathauto to[error]
/data/archive/drupal/modules/20100404203602/pathauto
rename(): The first argument to copy() function cannot be a directory in                    [warning]
/home/ga/local/drush/includes/drush.inc on line 523.
rename(/srv/www/dev.greenknowe.org/sites/all/modules/pathauto,/data/archive/drupal/modules/20100404203602/pathauto):[warning]
Success in /home/ga/local/drush/includes/drush.inc on line 523.
An error occurred at function : drush_pm_updatecode                                         [error]

This is similar to what you're getting, but slightly different. Different messages for different php versions, maybe? (Mine is subtly different than yours: PHP 5.2.10-2ubuntu6.4 with Suhosin-Patch 0.9.7)

According to the php rename manual page:

4.3.3 rename() is now able to rename files across partitions on *nix based systems.

However, it does not seem that the same is necessarily true for directories. Perhaps backup.inc should be using drush_core_call_rsync() to copy to the backup directory. In this case, the download should be done to a temporary directory, and the updated version should be copied back over with rsync --delete, just as Owen suggests in #759906: Update core without moving core files out of the way..

@mariomaric: If this looks right to you, then I'll close this issue as a duplicate of #759906.

izkreny’s picture

Status: Active » Closed (duplicate)

Yup, I can confirm - tested on VirtualBox Ubuntu 9.10 virtual machine with only one partition - it is working.

It is perfectly OK to close this issue if solving #759906: Update core without moving core files out of the way. will take care of this problem. ;)

Marked as duplicate, tnx for feedback Greg.