#StackBounty: #drush pm-update using linux cron fails

Bounty: 50

I use below script to update the drupal – core and modules – using the linux cron.

#!/bin/bash
perform_backup(){
cd "$1"
echo "Current working directory : $(pwd)"
if  /usr/bin/drush -r .  status bootstrap | grep -q 'Successful' #Check if a drupal website
then
  if /usr/bin/drush -r . ard --tar-options="--exclude=.git"
  then
    # If archive-dump was successful, then
    # Perform drush update without further backups
    /usr/bin/drush -r . -y pm-update --no-backup
  fi
else
#Do a git commit of the current working directory
git add .
git commit -m"CronBackup-$(date +%s)"
fi
}
export -f perform_backup
find /var/www/html/ -mindepth 1 -maxdepth 1 -type d -exec bash -c 'perform_backup "$0"' {} ;

The linux crontab entry is as follows.

0        0          *              *                0,3,6           /usr/bin/drupal-updater >> /var/log/site-update-log

and the log details which i got for one website from /var/log/site-update-log is like below

Current working directory : /var/www/html/example.com
/root/drush-backups/archive-dump/20170304000002/example.20170304_000002.tar.gz
Update information last refreshed: Sat, 2017-03-04 04:52
 Name               Installed  Proposed  Message
                    Version    version
 Metatag (metatag)  7.x-1.20   7.x-1.21  SECURITY UPDATE available
 Panels (panels)    7.x-3.8    7.x-3.9   Update available
 Views (views)      7.x-3.14   7.x-3.15  SECURITY UPDATE available
 Views Slideshow    7.x-3.5    7.x-3.7   Update available
 (views_slideshow)


Security and code updates will be made to the following projects: Metatag [metatag-7.x-1.21], Panels [panels-7.x-3.9], Views [views-7.x-3.15], Views Slideshow [views_slideshow-7.x-3.7]

Note: You have selected to not store backups.
Do you really want to continue with the update process? (y/n): y
Project metatag was updated successfully. Installed version is now 7.x-1.21.
Project panels was updated successfully. Installed version is now 7.x-3.9.
Project views was updated successfully. Installed version is now 7.x-3.15.
Project views_slideshow was updated successfully. Installed version is now 7.x-3.7.

However, in reality none of those modules were updated though the archive dump of the website was successful. When I did a pm-update from the document root, below is the result I got

[root@instance-1 somewebsite.com]# drush pm-update
Update information last refreshed: Sat, 2017-03-04 09:55
 Name               Installed  Proposed  Message                   
                    Version    version                             
 Metatag (metatag)  7.x-1.20   7.x-1.21  SECURITY UPDATE available 
 Panels (panels)    7.x-3.8    7.x-3.9   Update available          
 Views (views)      7.x-3.14   7.x-3.15  SECURITY UPDATE available 
 Views Slideshow    7.x-3.5    7.x-3.7   Update available          
 (views_slideshow)                                                 


Security and code updates will be made to the following projects: Metatag [metatag-7.x-1.21], Panels [panels-7.x-3.9], Views [views-7.x-3.15], Views Slideshow [views_slideshow-7.x-3.7]

Note: A backup of your project 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 with the update process? (y/n): n
Aborting.                                                            [cancel]
No database updates required                                         [success]
drush c'all' cache was cleared.                                             [success]
Finished performing updates.                                         [ok]
[root@instance-1 example.com]# 

The actual updates were made only during manual updation. What is the cause for this?


Note: The actual domain name is changed for security reasons


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.