Updating Drupals Minor or Patch Version Amber Himes Matz Twin - - PowerPoint PPT Presentation

updating drupal s minor or patch version
SMART_READER_LITE
LIVE PREVIEW

Updating Drupals Minor or Patch Version Amber Himes Matz Twin - - PowerPoint PPT Presentation

Keeping Drupal up-to-date Updating Drupals Minor or Patch Version Amber Himes Matz Twin Cities Drupal Camp June 2018 Amber Himes Matz Production M anb ger and Trainer twitter.com/amberhimesmatz In this session Terms and assumptions


slide-1
SLIDE 1

Updating Drupal’s Minor or Patch Version

Keeping Drupal up-to-date

Amber Himes Matz
 Twin Cities Drupal Camp June 2018

slide-2
SLIDE 2

Amber Himes Matz

Production Manbger and Trainer

twitter.com/amberhimesmatz

slide-3
SLIDE 3

@amberhimesmatz

In this session

Terms and assumptions Standard update procedure Tips for using Drush and Composer Related issues and resources

slide-4
SLIDE 4

Terminology

slide-5
SLIDE 5

@amberhimesmatz

Update

Update To update Drupal core’s minor or patch version, e.g. 8.4.0 to 8.5.4

  • r 8.5.2 to 8.5.4
slide-6
SLIDE 6

@amberhimesmatz

Upgrade

Upgrade (see also “Migrate”) To upgrade Drupal core from one major version to a higher one, e.g. 7.59 to 8.5.4 or 6.38 to 8.5.4

slide-7
SLIDE 7

Today we’re talking about updating (not upgrading)

slide-8
SLIDE 8

@amberhimesmatz

Semantic versioning

Drupal 8 uses semantic versioning Alias “semver” Composer uses it, too!

slide-9
SLIDE 9

@amberhimesmatz

Semantic Versioning

x.y.z x = Major version y = Minor version z = Patch version

slide-10
SLIDE 10

@amberhimesmatz

Semantic Versioning

x.y.z x = Major: Breaking change. Not backwards compatible. y = Minor: New feature(s), no breaking changes z = Patch: bug fix, security patch, no breaking change

slide-11
SLIDE 11

@amberhimesmatz

Semantic Versioning

x.y.z x = Major: Breaking change. Not backwards compatible. y = Minor: New feature(s), no breaking changes z = Patch: bug fix, security patch, no breaking change

slide-12
SLIDE 12

@amberhimesmatz

Release schedule

Drupal releases a minor update every 6 months Patch releases occur as needed and may contain bug or security fixes

slide-13
SLIDE 13

Evaluate the release

slide-14
SLIDE 14

@amberhimesmatz

release notes

Minor release? x.y.z What new features does it have? Patch release? x.y.z Security release? Critical? Time-sensitive? Bug fix?

slide-15
SLIDE 15

Assumptions & prerequisites

slide-16
SLIDE 16

@amberhimesmatz

Assumptions

Drupal 8

slide-17
SLIDE 17

@amberhimesmatz

Prereqs

You have: Administer software updates permission, admin access, and file access

slide-18
SLIDE 18

@amberhimesmatz

Assumptions

You know: Command line basics and/or the ability to look up commands (But these are mostly shortcuts.)

slide-19
SLIDE 19

@amberhimesmatz

Assumptions

You know how to use: Version control with Git And you have a process for getting files to the ‘live’ site

slide-20
SLIDE 20

@amberhimesmatz

Assumptions

Composer commands: Replace command composer with PATH/TO/composer See getcomposer.org/download

slide-21
SLIDE 21

@amberhimesmatz

Assumptions

Your process may be different if: Your hosting provider has proprietary tools for updating Drupal core But it still helps to understand various processes and their pros and cons

slide-22
SLIDE 22

@amberhimesmatz

The problem

You may have used Composer to install a new module with a dependency but you didn’t install Drupal with Composer and you’re wondering why this is so hard.

slide-23
SLIDE 23

there are 3 parts to a drupal site

slide-24
SLIDE 24

@amberhimesmatz

3 parts of drupal

Code Database Files

slide-25
SLIDE 25

@amberhimesmatz

Code

core and vendor directories Scaffolding files (individual files one level above core directory or in sites) Example files

slide-26
SLIDE 26

Core Core Depfndencies (Composer) Postibly customized Postibly customized Custom! Do not overwrite. Custom! Do not overwrite. Custom! Do not overwrite.

Drupal Code

@amberhimesmatz

slide-27
SLIDE 27

@amberhimesmatz

Database

The database used to store a Drupal site’s content, configuration, state, and logging information.

slide-28
SLIDE 28

@amberhimesmatz

Files

public and private files directories Uploaded files, config, image derivatives, various caches, translations, etc. Not under version control, but needs to be backed-up

slide-29
SLIDE 29

@amberhimesmatz

Project files

Your project may have other special files and directories Build scripts, backups, etc.

slide-30
SLIDE 30

Backup

slide-31
SLIDE 31

@amberhimesmatz

3 areas to Backup

Code Database Files

slide-32
SLIDE 32

@amberhimesmatz

Backup code

Code Should be version controlled. If it’s not, do it! Check the site’s .gitignore to see what’s not backed up by version control Backup custom .htaccess, robots.txt, etc.

slide-33
SLIDE 33

@amberhimesmatz

drush sql-dump

Database backup with Drush drush sql-dump > ../backups/ YYYY-MM-DD-filename.sql

slide-34
SLIDE 34

@amberhimesmatz

drush sql-dump

Database backup with Drush See options for sql-dump at drushcommands.com

slide-35
SLIDE 35

@amberhimesmatz

drush sql-dump

Configure sql-dump with drush.yml See https://github.com/drush-

  • ps/drush/blob/master/examples/

example.drush.yml

slide-36
SLIDE 36

@amberhimesmatz

mysqldump

Database backup with mysqldump mysqldump -u [username] -p [dbname] | gzip -9 > ../ backups/YYYY-MM-DD- filename.sql.gz

slide-37
SLIDE 37

@amberhimesmatz

phpmyadmin

Database PHPMyAdmin Select database > Export

slide-38
SLIDE 38

@amberhimesmatz

tools from host

See hosting provider’s dashboard for database backup buttons or tools See also https://www.lullabot.com/ articles/importexport-large-mysql- databases

slide-39
SLIDE 39

@amberhimesmatz

Backup files

Files (public and private files) sites directory <== do not overwrite! settings.php! sites/*/files

slide-40
SLIDE 40

@amberhimesmatz

Backup files

Files Drupal-friendly hosts will have dashboard tools for backing up “Files”

slide-41
SLIDE 41

@amberhimesmatz

tar w/ gzip

tar With gzip compression tar -czvf ../backups/YYYY-MM- DD-files.tar.gz sites/

slide-42
SLIDE 42

@amberhimesmatz

tar w/ bzip2

tar With bzip2 compression tar -cjvf ../backups/YYYY-MM- DD-sitename.tar.bz2 sites/

slide-43
SLIDE 43

@amberhimesmatz

backup and migrate

Recommended module: Backup and Migrate https://www.drupal.org/project/ backup_migrate

slide-44
SLIDE 44

Standard update procedure

slide-45
SLIDE 45

@amberhimesmatz

Standard Update

Step 1. Log in as user with ‘Administer software updates’ permission.

slide-46
SLIDE 46

@amberhimesmatz

Standard update

Step 2: Put your site in maintenance mode. Administration > Configuration > Development > Maintenance mode admin/config/development/maintenance

slide-47
SLIDE 47

@amberhimesmatz

standard update

Enable this checkbox!

slide-48
SLIDE 48

Do yourself a favor and keep the maintenance mode page open in a tab

slide-49
SLIDE 49

Step 3. Determine if your site was installed with composer

slide-50
SLIDE 50

@amberhimesmatz

Managed w/ Composer?

Run 
 composer info drupal/core Success? Your project is managed with Composer. Failure? It’s not.

slide-51
SLIDE 51

@amberhimesmatz

Managed w/ Composer?

Look at composer.json in root directory. Is drupal/core listed under ‘require’?

  • YES. Managed w/ Composer
  • NO. Not. (Even if listed under ‘replace’.)
slide-52
SLIDE 52

If project is not managed with composer

slide-53
SLIDE 53

@amberhimesmatz

Not composer-managed

Step 4: Remove old code Should be done on local development or staging site and deployed to live site as usual.

slide-54
SLIDE 54

@amberhimesmatz

Not composer-managed

Step 4: Remove old code Remove core and vendor directories rm -rf core vendor rm -f *.* .*

slide-55
SLIDE 55

@amberhimesmatz

not composer-managed

Step 5a: Download the update from drupal.org/project/drupal wget https://www.drupal.org/files/ projects/drupal-x.y.z.tar.gz

slide-56
SLIDE 56

@amberhimesmatz

not composer-managed

Step 5b. Extract the archive file. tar -zxvf drupal-x.y.z.tar.gz

slide-57
SLIDE 57

Warning!
 Do not overwrite your modules, themes, profiles, or sites directories.

slide-58
SLIDE 58

@amberhimesmatz

not composer-managed

Step 6. Apply new code. Copy all files and directories except modules, themes, profiles, and sites from the update to your site.

slide-59
SLIDE 59

Core Core Depfndencies (Composer) Postibly customized Postibly customized Custom! Do not overwrite. Custom! Do not overwrite. Custom! Do not overwrite.

Drupal Code

@amberhimesmatz

slide-60
SLIDE 60

If site is managed with composer

slide-61
SLIDE 61

@amberhimesmatz

Managed w/ Composer

Run 
 composer update drupal/core 


  • -with-dependencies

replaces steps 4-6!

slide-62
SLIDE 62

@amberhimesmatz

Standard update

Step 7. Check release notes for changes to default.settings.php

slide-63
SLIDE 63

@amberhimesmatz

Standard update

If default.settings.php was changed:

  • 1. Locate default.settings.php
  • 2. Duplicate your settings.php with new name
  • 3. Copy new default.settings.php to settings.php
  • 4. Re-apply customizations from previous one
slide-64
SLIDE 64

@amberhimesmatz

Standard update

Step 8. Reapply customizations to .htacess and robots.txt (Because you backed up your

  • riginal ones already, right?)
slide-65
SLIDE 65

@amberhimesmatz

Standard update

Step 9. Upload new code (including vendor directory) to “live” environment using your regular deployment method.

slide-66
SLIDE 66

@amberhimesmatz

Standard update

Step 10a: Open ‘live’ settings.php in text editor. By default, access to update.php is

  • blocked. In settings.php, find

update_free_access and set to TRUE

slide-67
SLIDE 67

@amberhimesmatz

Standard update

Step 10b: Run database update(s) Access example.com/update.php in a browser Follow instructions

slide-68
SLIDE 68

@amberhimesmatz

Standard Update

slide-69
SLIDE 69

@amberhimesmatz

Standard Update

slide-70
SLIDE 70

@amberhimesmatz

Standard update

Step 10c: Edit ‘live’ settings.php again. Lock down update.php. Find update_free_access and set to FALSE

slide-71
SLIDE 71

@amberhimesmatz

Standard update

Step 11. Verify site is working as expected. Go to admin/reports/status

slide-72
SLIDE 72

@amberhimesmatz

Standard Update

Step 12: Turn off maintenance mode Go to admin/config/development/ maintenance Disable checkbox

slide-73
SLIDE 73

Ta-Da! YOu’ve updated your drupal site!

N

  • t

eb r s ! Take a walk! Ice crebm time!

slide-74
SLIDE 74

Tips for using drush to update

slide-75
SLIDE 75

@amberhimesmatz

Drush

NOTE: For updating sites <= 8.4 use Drush 8 Drush 9 (> D8.4) assumes Composer- based methods to update core and contrib

slide-76
SLIDE 76

@amberhimesmatz

Drush 8 (only)

Backup codebase, database, and files

drush archive-dump https://drushcommands.com/drush-8x/ core/archive-dump/

slide-77
SLIDE 77

@amberhimesmatz

Drush

To put your site in maintenance mode:

drush sset system.maintenance_mode 1

drush cache-rebuild

slide-78
SLIDE 78

Why? Drupal core AND its dependencies (vendor) both need updating

slide-79
SLIDE 79

Warning! 
 Do not use 
 drush up

  • r drush pm-update!

No! Bad! Don’t do it!

slide-80
SLIDE 80

@amberhimesmatz

Drush

To update the database

drush updatedb

slide-81
SLIDE 81

@amberhimesmatz

Drush

To take site off maintenance mode

drush sset system.maintenance_mode 0 drush cache-rebuild

slide-82
SLIDE 82

Tips: updating a site Installed w/ Drupal composer template

slide-83
SLIDE 83

@amberhimesmatz

Didn’t I just say this?

NOTE: Do not attempt to use drush pm-update to update a site that was created with Composer.

slide-84
SLIDE 84

@amberhimesmatz

Composer template

Drupal Composer Template https://github.com/drupal- composer/drupal-project

slide-85
SLIDE 85

@amberhimesmatz

Composer template

Step 0: Put your site in maintenance mode.

cd web drush sset system.maintenance_mode 1 drush cache-rebuild cd ../

slide-86
SLIDE 86

@amberhimesmatz

Composer template

Step 0: Check your composer.json for version constraints and update if needed. “require”: { ... “drupal/core”: “^8.5.3”, ...}

slide-87
SLIDE 87

@amberhimesmatz

Composer Template

Step 1: Update core and its dependencies composer update drupal/core webflo/drupal-core-require-dev symfony/* --with-dependencies

slide-88
SLIDE 88

@amberhimesmatz

Composer template

Step 2: Determine if any scaffolding files have changed git diff

slide-89
SLIDE 89

@amberhimesmatz

Composer template

Step 3: Restore any customizations to .htaccess or robots.txt

slide-90
SLIDE 90

@amberhimesmatz

Composer template

Consult the README of the project to verify instructions or troubleshoot. But, understand that Composer docs might be a better place for some questions.

slide-91
SLIDE 91

@amberhimesmatz

Composer Template

Gotcha! Version constraints in composer.json only allow updates within a minor version. i.e. 8.3.7 -> 8.3.9 (not to 8.5.3).

slide-92
SLIDE 92

@amberhimesmatz

Composer Template

Gotcha! Incompatible dependencies in your composer.json

slide-93
SLIDE 93

@amberhimesmatz

Composer Template

Important! Do not deploy development dependencies to your live site. Run composer install --no-dev 
 and commit changes to version control before deploying to production.

slide-94
SLIDE 94

@amberhimesmatz

Composer template

Step 5. Update the database

drush updatedb

slide-95
SLIDE 95

@amberhimesmatz

Composer template

big bullet Huge bullet super-important bullet

Step 6. Take site off maintenance mode

drush sset system.maintenance_mode 0 drush cache-rebuild

slide-96
SLIDE 96

Related drupal.org Issues

slide-97
SLIDE 97

@amberhimesmatz

Composer support

Proposal: Composer Support in Core Initiative https://www.drupal.org/project/ ideas/issues/2958021

slide-98
SLIDE 98

@amberhimesmatz

Issues

Improve instructions to core/ UPDATE.txt https://www.drupal.org/project/ drupal/issues/2867757

slide-99
SLIDE 99

using composer to manage your drupal site

slide-100
SLIDE 100

@amberhimesmatz

composerize Drupal

Comperize Drupal Composer plugin Convert a non-Composer-managed Drupal project to a Composer-managed one! https://github.com/grasmash/ composerize-drupal

slide-101
SLIDE 101

@amberhimesmatz

Drupal Console

Drupal Console’s composerize command https://hechoendrupal.gitbooks.io/ drupal-console/content/en/commands/ composerize.html

slide-102
SLIDE 102

@amberhimesmatz

Composerize module

Composerize Module “Not ready for prime time.” https://www.drupal.org/project/ composerize

slide-103
SLIDE 103

@amberhimesmatz

DIY Composerize

Free tutorial on Drupalize.Me Use Composer with Your Drupal Project by Matthew Grasmick https://drupalize.me/tutorial/use- composer-your-drupal-project

slide-104
SLIDE 104

Keeping Track of Updates

slide-105
SLIDE 105

@amberhimesmatz

keeping track of updates

On your site: Reports > Available updates > Settings Enter email addresses to be notified daily or weekly

slide-106
SLIDE 106

@amberhimesmatz

keeping track of updates

Subscribe to security announcements mailing list Log in to drupal.org On your account page: 
 Edit > My newsletters tab

slide-107
SLIDE 107

@amberhimesmatz

keeping track of updates

On Twitter: Follow @drupalsecurity

slide-108
SLIDE 108

@amberhimesmatz

keeping track of updates

Subscribe to RSS Feeds: core security updates
 https://www.drupal.org/security/rss.xml contributed project updates
 https://www.drupal.org/security/contrib/rss.xml public service announcements
 https://www.drupal.org/security/psa/rss.xml

slide-109
SLIDE 109

@amberhimesmatz

keeping track of updates

On Drupal Slack: https://www.drupal.org/slack Join #announcements channel

slide-110
SLIDE 110

More resources

slide-111
SLIDE 111

@amberhimesmatz

Security and maintenance

Drupal 8 User Guide Chapter 13: Security and Maintenance https://drupalize.me/series/user- guide/security-chapter

slide-112
SLIDE 112

@amberhimesmatz

Tutorial

Update Drupal’s Minor Version https://drupalize.me/tutorial/ update-drupals-minor-version

slide-113
SLIDE 113

@amberhimesmatz

Composer

Introduction to Composer for Drupal Users Drupalize.Me tutorial series https://drupalize.me/series/ introduction-composer-drupal-users

slide-114
SLIDE 114

@amberhimesmatz

Composer

Official Composer Site https://getcomposer.org

slide-115
SLIDE 115

Happy updating!