drush

Create custom Drush command

Create in module directory file named drush.services.yml with similar content:

services:
  custom_base.commands:
    class: Drupal\custom_base\Commands\CustomCommands
    arguments:
      - '@config.factory'
      - '@entity_type.manager'
      - '@database'
    tags:
      -  { name: drush.command }

In Drupal\custom_base\src\Commands need to create file CustomCommands.php:

Drush commands

Import translations:

drush locale:import --override=all fr modules/custom/base/translations/base.fr.po && drush cr

 Execute migrate:

drush migrate-import entity_invoice --update

 Execute cron job by name:

drush simple-cron incoming_session_archive --force

How can I change theme? For Drupal8+: 

Database manipulations

Restore database:

drush sql:drop -y && pv ~/www/SITE_NAME/web/sites/default/files/backups/last.mysql | drush sql-cli --extra=-A

Restore zipped database:

drush sql:drop -y && unzip -p ~/www/_db_backups/SITE_NAME/last.mysql.zip | pv | drush sql-cli --extra=-A


Backup database:

drush sql:dump --structure-tables-list="cache,cache_*" > new.sql 
Subscribe to drush