Using Drush lock files with contributed modules

Drush

Drush includes the up parameter to allow you to quickly update your website's modules. Although this parameter can be convenient, updating a live website before adequate testing could cause problems or outages. It can also cause modified modules (such as those used by Acquia Remote Administration in the RA environment) to be overwritten, losing their modification. To protect against this, you can add Drush lock files to your environment.

You have the option of either using Drush aliases or creating the locks by directly connecting to your server.

Using Drush aliases

If you're already familiar with Drush aliases, you can issue Drush commands from a local installation and have them take place on a remote server.

To do this, use a Drush alias that's similar to the following from a command prompt (replacing with the module's name, and with a descriptive message):

drush @mysite.dev pm-updatestatus --lock= --lock-message="" 

This command has the same effect as creating a manual lock directly on the server.

Creating locks on the server

If you're comfortable with working on the server itself (or working directly on the server is a requirement), you can either use Drush or create the lock manually:

Using Drush

You can use Drush to prevent other users from updating modules through Drush. You can also remove the locks from the modules if you need to remove the protection for whatever reason.

Locking modules using Drush

To lock a module and prevent other users from updating it with Drush, complete the following steps:

  1. Enable livedev mode on your website.
  2. Sign in to your server using SSH.
  3. Change to your website's docroot.
  4. Run a command similar to the following to lock the module (replacing with the module's name, and with a descriptive message):
    drush pm-updatestatus --lock= --lock-message="" 
  5. Commit the changes.
  6. Disable livedev mode.

Removing a module lock with Drush

To unlock modules if locking is no longer needed:

  1. Enable livedev mode on your website.
  2. Sign in to your server using SSH.
  3. Change to your website's docroot.
  4. Run a command similar to the following to lock the module (replacing with the module's name):
    drush pm-updatestatus --unlock=
  5. Commit the changes.
  6. Disable livedev mode.

Manually creating locks

If you don't want to use Drush, you can also manually create (or remove) module locks in your code repository.

Creating a lock

To create a module lock in the repository, complete the following steps:

  1. In your code repository, navigate to the folder that contains the module to which you want to add a lock.
  2. Create a file called .drush-lock-update that contains text describing the need for the module lock, just as you would use for the lock message in --lock-message="" . The file supports line breaks.
  3. Commit the file to your repository.

Repeat the process for each module that requires a lock.

Deleting a lock

To remove a lock from a module, complete the following steps:

  1. In your code repository, navigate to the folder that contains the module that you want to unlock.
  2. Delete the .drush-lock-update file.
  3. Commit your changes to the repository.

Contact supportStill need assistance? Contact Acquia Support