2017 © Pedro Peláez
 

library m2install

Magento 2 Bash Install/Restore Script

image

yvoronoy/m2install

Magento 2 Bash Install/Restore Script

  • Sunday, June 24, 2018
  • by yvoronoy
  • Repository
  • 12 Watchers
  • 39 Stars
  • 84 Installations
  • Shell
  • 0 Dependents
  • 0 Suggesters
  • 17 Forks
  • 7 Open issues
  • 19 Versions
  • 9 % Grown

The README.md

Magento 2 Bash Install/Restore Script

Docker Image CI GitHub closed pull requests GitHub closed issues, (*1)

This script is designed to simplify the installation process of Magento 2 and rapid deployment of merchant code and DB dumps., (*2)

m2install can be a helpful tool for support teams and teams who often need to install or deploy merchant backups or dumps., (*3)

The main purpose of this script is run m2install, wait a bit and get a working magento instance. Don't waste time on routine operations., (*4)

If you have any issues please report them to https://github.com/yvoronoy/m2install/issues, (*5)

What can m2install exactly do?

  • Can automatically restore backup files created by
    • php bin/magento setup:backup --code --db
  • Can automatically restore support dumps created by Enterpsie Support Tool
    • php bin/magento support:backup:code (db)
  • Script can automatically install vanilla magento

Installation

Download latest version by curl, (*6)

curl -o m2install.sh https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install.sh

You can install by composer, (*7)

composer require yvoronoy/m2install

In case you are using bash completion you can download completion for this script., (*8)

#For Linux User
curl -o /etc/bash_completion.d/m2install-bash-completion https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install-bash-completion

#For OSX User with brew
curl -o /usr/local/etc/bash_completion.d/m2install-bash-completion https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install-bash-completion

Usage

$ m2install.sh --help
m2install.sh is designed to simplify the installation process of Magento 2
and deployment of client dumps created by Magento 2 Support Extension.

Usage: m2install.sh [options]
Options:
    -h, --help                           Get this help.
    -s, --source (git, composer)         Get source code.
    -f, --force                          Install/Restore without any confirmations.
    --sample-data (yes, no)              Install sample data.
    --ee                                 Install Enterprise Edition.
    --b2b                                Install B2B Extension.
    -v, --version                        Magento Version - it means: Composer version or GIT Branch
    --mode (dev, prod)                   Magento Mode. Dev mode does not generate static & di content.
    --quiet                              Quiet mode. Suppress output all commands
    --skip-post-deploy                   Skip the post deploy script if it is exist
    --step (restore_code,restore_db      Specify step through comma without spaces.
        configure_db,configure_files     - Example: m2install.sh --step restore_db,configure_db
        installB2B --b2b                 - Example: m2install.sh --step installB2B --b2b
        installLiveSearch)               - Example: m2install.sh --step installLiveSearch
    --restore-table                      Restore only the specific table from DB dumps
    --debug                              Enable debug mode
    --php                                Specify path to PHP CLI (php71 or /usr/bin/php71)
    --remote-db                          Remote database name
    --es-host, --elasticsearch-host      Set the Elasticsearch host
    --es-port, --elasticsearch-port      Set the Elasticsearch port
    --uninstall                          Delete database and application from the current folder
    _________________________________________________________________________________________________
    --ee-path (/path/to/ee)              (DEPRECATED use --ee flag) Path to Enterprise Edition.

How to deploy backup/support dumps

In order to deploy the customer dumps you need:, (*9)

  • Put DB and code dumps to new directory
  • Go to directory and run m2install

How to install Magento 2 using GIT

To install Magento 2 from git repository run m2install with --source git param * m2install --source git or * m2install -s git, (*10)

How to install Magento 2 using Composer

To install Magento 2 from composer run m2install with --source composer param * m2install --source composer or * m2install -s composer, (*11)

How to Install Magento 2 with Sample Data

  • Run m2install
  • Use wizard to install the sample data.

How to Install Magento 2 with B2B extension

With wizard * Run m2install * Use wizard to install the B2B, (*12)

With CLI flags * m2install --ee --b2b or * m2install --step installB2B --b2b if you already have Magento EE, (*13)

Remember that you have to install Enterprise Edition to be able to install B2B extension, (*14)

Wizard

m2install shows you wizard on first run and prompts to save entered values to config file., (*15)

$ m2install.sh 
Current Directory: /Users/yvoronoy/Sites/m2/ee202
Configuration loaded from:
Enter Server Name of Document Root (default: http://mage2.dev/): 
Enter Base Path (default: ee202): 
Enter DB Host (default: localhost): 
Enter DB User (default: root): 
Enter DB Password: 
Enter DB Name (default: root_ee202): 
Do you want to install Sample Data (y/N) n
Enter Path to EE or [nN] to skip EE installation: n
--------------------------------------------------
BASE URL: http://mage2.dev/ee202/
DB PARAM: root@localhost
DB NAME: root_ee202
Sample Data will NOT be installed.
Magento EE will NOT be installed.
In order to generate static/di content, add mode param: m2install.sh --mode prod
Are you sure? [y/N] 

How to use configuration files

The config file allows you to store params for DB and URL. Example of config file, (*16)

HTTP_HOST=http://your-mage-host.com/
BASE_PATH=your/base/path/${CURRENT_DIR_NAME}
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=dbpassword

When you first run m2install script, it shows wizard which prompts to save the config file to your home directory., (*17)

m2install uses fallback mechanism to find config files recursively from home directory to current directory. For example if you want to install magento to directory ~/www/m2/ga/magento2ee, (*18)

you can override config file which is placed in your home directory., (*19)

~/.m2install.conf
~/www/.m2install.conf
~/www/m2/.m2install.conf
~/www/m2/ga/.m2install.conf
~/www/m2/ga/magento2ee/.m2install.conf

How to use ssh tunnels for remote DB connection

Make sure that you have correct parameters in .m2install.conf file Parameters example:, (*20)

REMOTE_DB_HOST=mysql-host:3306
REMOTE_HOST=user@ssh.domain
REMOTE_KEY=/Users/path/to/ssh_key
LOCAL_PORT=33060

As a result you will get:, (*21)

ssh -i /Users/path/to/ssh_key -o StrictHostKeyChecking=no -4fN -L 33060:mysql-host:3306 user@ssh.domain >> /dev/null

All created ssh tunnels pids located in file kill_tunnel.sh in Magento root folder (or pub), (*22)

To run you will need only code dump file (Example code.tar.gz)., (*23)

m2install.sh --remote-db database_name

Make attention that in --remote-db database_name first part before "_" is database user name, (*24)

Make attention that in bootstrap added SECURE and UNSECURE BASE_URL to prevent DB modification, (*25)

$_ENV['CONFIG__DEFAULT__WEB__UNSECURE__BASE_URL'] = 'http://magento.local/';

The Versions

24/06 2018

dev-fix/getTablePrefix

dev-fix/getTablePrefix

Magento 2 Bash Install/Restore Script

  Sources   Download

GNU

by Yaroslav Voronoy

23/06 2018

dev-FIX-141

dev-FIX-141

Magento 2 Bash Install/Restore Script

  Sources   Download

GNU

by Yaroslav Voronoy

16/04 2018

dev-master

9999999-dev

Magento 2 Bash Install/Restore Script

  Sources   Download

GNU

by Yaroslav Voronoy

06/04 2018

v0.1.1-beta

0.1.1.0-beta

  Sources   Download

06/04 2018

v0.1.5-beta

0.1.5.0-beta

  Sources   Download

06/04 2018

v0.1.6-beta

0.1.6.0-beta

  Sources   Download

06/04 2018

v0.1.7-beta

0.1.7.0-beta

  Sources   Download

06/04 2018

v0.1.8-beta

0.1.8.0-beta

  Sources   Download

06/04 2018

v0.1.9-beta

0.1.9.0-beta

  Sources   Download

06/04 2018

1.0.0

1.0.0.0

  Sources   Download

08/02 2018

dev-iskliarenko-patch-1

dev-iskliarenko-patch-1

Magento 2 Bash Install/Restore Script

  Sources   Download

GNU

by Yaroslav Voronoy

21/09 2017

dev-develop

dev-develop

Magento 2 Bash Install/Restore Script

  Sources   Download

GNU

by Yaroslav Voronoy

19/08 2017

dev-travis_unit

dev-travis_unit

Magento 2 Bash Install/Restore Script

  Sources   Download

GNU

by Yaroslav Voronoy

13/06 2017

1.0.4

1.0.4.0

Magento 2 Bash Install/Restore Script

  Sources   Download

GNU

by Yaroslav Voronoy

13/06 2017

dev-travis_restore-table

dev-travis_restore-table

Magento 2 Bash Install/Restore Script

  Sources   Download

GNU

by Yaroslav Voronoy

07/06 2017

1.0.3

1.0.3.0

Magento 2 Bash Install/Restore Script

  Sources   Download

GNU

by Yaroslav Voronoy

10/11 2016

1.0.2

1.0.2.0

Magento 2 Bash Install/Restore Script

  Sources   Download

GNU

by Yaroslav Voronoy

08/07 2016

1.0.x-dev

1.0.9999999.9999999-dev

Magento 2 Bash Install/Restore Script

  Sources   Download

GNU

by Yaroslav Voronoy

14/06 2016

1.0.1

1.0.1.0

Magento 2 Bash Install/Restore Script

  Sources   Download

GNU

by Yaroslav Voronoy