2017 © Pedro Peláez
 

robo-tasks robo-digipolis-deploy

Deploy tasks for Robo Task Runner

image

digipolisgent/robo-digipolis-deploy

Deploy tasks for Robo Task Runner

  • Thursday, July 5, 2018
  • by zero2one
  • Repository
  • 3 Watchers
  • 2 Stars
  • 8,725 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 23 Versions
  • 17 % Grown

The README.md

Robo Digipolis Deploy

Deploy tasks for Robo Task Runner, (*1)

Latest Stable Version Latest Unstable Version Total Downloads License, (*2)

Build Status Maintainability Test Coverage PHP 7 ready, (*3)

Tasks in this package

PushPackage

$auth = new \DigipolisGent\Robo\Task\Deploy\Ssh\Auth\KeyFile('user', '/home/myuser/.ssh/id_dsa');
$result = $this->taskPushPackage('192.168.1.1', $auth)
    ->port(8022)
    ->timeout(15)
    ->destinationFolder('/folder/on/server')
    ->package('/path/to/local/package.tar.gz')
    ->run();

SFTP

$auth = new \DigipolisGent\Robo\Task\Deploy\Ssh\Auth\KeyFile('user', '/home/myuser/.ssh/id_dsa');
$result = $this->taskSFTP('192.168.1.1', $auth)
    ->port(8022)
    ->timeout(15)
    // Download file from server.
    ->get('/path/to/remote/file.txt', '/path/to/local/file.txt')
    // Upload file to server.
    ->put('/path/to/remote/file.txt', '/path/to/local/file.txt')
    ->run();

Ssh

$auth = new \DigipolisGent\Robo\Task\Deploy\Ssh\Auth\KeyFile('user', '/home/myuser/.ssh/id_dsa');
$result = $this->taskSsh('192.168.1.1', $auth)
    ->port(8022)
    ->timeout(15)
    // Set the remote directory to execute the commands in.
    ->remoteDirectory('/path/to/remote/dir')
    ->exec('composer install')
    ->run();

SymlinkFolderFileContents

$result = $this
    ->taskSymlinkFolderFileContents('/path/to/source', '/path/to/destination')
    ->run();

As this command will most likely be used to symlink config files on a server during deployment, this task should be used in a command that runs on the server. For example:, (*4)

RoboFile.php on the server (let's say 192.168.1.1 in folder /path/to/remote/dir):, (*5)

<?php

class RoboFile extends \Robo\Tasks
{
    use \DigipolisGent\Robo\Task\Deploy\loadTasks;

    /**
     * Creates the symlinks.
     */
    public function symlinks($source, $dest)
    {
        $this
            ->taskSymlinkFolderFileContents($source, $dest)
            ->run();
    }
}

RoboFile.php on the build server / your local machine:, (*6)

<?php

class RoboFile extends \Robo\Tasks
{
    use \DigipolisGent\Robo\Task\Deploy\loadTasks;

    /**
     * Creates the symlinks.
     */
    public function symlinks($source, $dest)
    {
        $auth = new \DigipolisGent\Robo\Task\Deploy\Ssh\Auth\KeyFile('user', '/home/myuser/.ssh/id_dsa');
        $this->taskSsh('192.168.1.1', $auth)
            ->port(8022)
            ->timeout(15)
            ->remoteDirectory('/path/to/remote/dir')
            ->exec('vendor/bin/robo symlink ' . $source . ' ' . $dest)
            ->run();
    }
}

DatabaseBackup

$filesystemConfig = [
    'local' => [
        'type' => 'Local',
        'root' => '/home/myuser/backups',
    ],
];

$dbConfig = [
    'development' => [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'password',
        'database' => 'test',
        'singleTransaction' => true,
        'ignoreTables' => [],
    ],
    'production' => [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'password',
        'database' => 'test',
        'ignoreTables' => [],
        'structureTables' => [],
        'tables' => [],
        'dataOnly' => false,
        'orderedDump' => false,
        'singleTransaction' => true,
        'extra' => '--opt',
    ],
];
// Store a backup of the development database in /home/myuser/backups/dev.sql.tar.gz.
$result = $this->taskDatabaseBackup($filesystemConfig, $dbConfig)
    ->database('development')
    ->destination('dev.sql')
    ->compression('tar')
    ->run();

DatabaseRestore

$filesystemConfig = [
    'local' => [
        'type' => 'Local',
        'root' => '/home/myuser/backups',
    ],
];

$dbConfig = [
    'development' => [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'password',
        'database' => 'test',
        'singleTransaction' => true,
        'ignoreTables' => [],
    ],
    'production' => [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'password',
        'database' => 'test',
        'ignoreTables' => [],
        'structureTables' => [],
        'tables' => [],
        'dataOnly' => false,
        'orderedDump' => false,
        'singleTransaction' => true,
        'extra' => '--opt',
    ],
];
// Restore a backup of the development database located at /home/myuser/backups/dev.sql.tar.gz.
$result = $this->taskDatabaseRestore($filesystemConfig, $dbConfig)
    ->database('development')
    ->source('dev.sql.tar.gz')
    ->compression('tar')
    ->run();

File system configuration options

More information on the configuration options for the file systems can be found at https://github.com/backup-manager/backup-manager., (*7)

Database configuration options

More information on the configuration options for the databases can be found at https://github.com/backup-manager/backup-manager. However, we provide our own MySql database handler. The configuration options are explained below:, (*8)

$dbConfig = [
    'production' => [
        // Specify it's a mysql database.
        'type' => 'mysql',
        // Specify the database credentials.
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => 'password',
        'database' => 'test',
        // Tables to exclude from the export. This option will be ignored if the
        // 'tables' configuration option is set, because all tables will be
        // excluded except the ones specified in the 'tables' option. Therefore,
        // adding a table to the 'ignoreTables' would be the same as omitting it
        // from tbe 'tables' option if that option has a non-empty) value.
        'ignoreTables' => [],
        // Tables to only export the table structure for. A good example would
        // be a cache table, since most of the time you wouldn't want this
        // table's data in a backup. The structure of the tables specified here
        // will be exported even if the 'tables' configuration options has a
        // (non-empty) value and these tables are not in it.
        'structureTables' => [],
        // Tables to export. Leave empty to export all tables (except those
        // specified in the 'ignoreTables' configuration option).
        'tables' => [],
        // Export only data, not table structure.
        'dataOnly' => false,
        // Order by primary key and add line breaks for efficient diff in
        // revision control. Slows down the dump.
        'orderedDump' => false,
        // If singleTransaction is set to true, the --single-transcation flag
        // will be set. This is useful on transactional databases like InnoDB.
        // http://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_single-transaction
        'singleTransaction' => true,
        // Extra options to pass to mysqldump (e.g. '--opt --quick').
        'extra' => '--opt',

    ],
];

Commands in this package

This package provides default commands wich you can use in your RoboFile.php like so:, (*9)

class RoboFile extends \Robo\Tasks
{
    use \DigipolisGent\Robo\Task\Deploy\Commands\loadCommands;
}

digipolis:database-backup

vendor/bin/robo digipolis:database-backup [DATABASE] [OPTIONS], (*10)

Use events for default configuration

Implement an on-event hook for the digipolis-db-config event to return the datbase config as specified above used by this command. For example:, (*11)

/**
 * @hook on-event digipolis-db-config
 */
public function defaultDbConfig()
{
    $dbConfig = [];
    $dbConfig['default'] = [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => '$up3r$3cr3tP@$$w0rD',
        'database' => 'my_database',
        'structureTables' => [],
        'extra' => '--skip-add-locks --no-tablespaces',
    ];

    return $dbConfig;
}

Arguments

DATABASE

The database config key. See above for more details. In de given example, this argument would have to be 'production'. Defaults to 'default'., (*12)

Options

--file-system-config, -fsconf

Path to a PHP file containing filesystem config as documented at https://github.com/backup-manager/backup-manager. Defaults to the root directory of the local filesystem., (*13)

--database-config, -dbconf

Path to a PHP file containing database config as documented at https://github.com/backup-manager/backup-manager. Defaults to a database with the name of the current working directory as database name, on localhost port 3306, user root and an empty password., (*14)

--compression, -c

The compression to use for this backup. Defaults to tar., (*15)

--destination, -d

The destination file for this backup. Defaults to project.tar.gz in the current working directory., (*16)

--destination-type, -dtype

The destination type (e.g. local, dropbox, ftp). Defaults to local., (*17)

digipolis:database-restore

vendor/bin/robo digipolis:database-restore [DATABASE] [OPTIONS], (*18)

Use events for default configuration

Implement an on-event hook for the digipolis-db-config event to return the datbase config as specified above used by this command. For example:, (*19)

/**
 * @hook on-event digipolis-db-config
 */
public function defaultDbConfig()
{
    $dbConfig = [];
    $dbConfig['default'] = [
        'type' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'user' => 'root',
        'pass' => '$up3r$3cr3tP@$$w0rD',
        'database' => 'my_database',
        'structureTables' => [],
        'extra' => '--skip-add-locks --no-tablespaces',
    ];

    return $dbConfig;
}

Arguments

DATABASE

The database config key. See above for more details. In de given example, this argument would have to be 'production'. Defaults to 'default'., (*20)

Options

--file-system-config, -fsconf

Path to a PHP file containing filesystem config as documented at https://github.com/backup-manager/backup-manager. Defaults to the root directory of the local filesystem., (*21)

--database-config, -dbconf

Path to a PHP file containing database config as documented at https://github.com/backup-manager/backup-manager. Defaults to a database with the name of the current working directory as database name, on localhost port 3306, user root and an empty password., (*22)

--compression, -c

The compression of the given backup. Defaults to tar., (*23)

--source, -s

The source file to restore. Defaults to project.tar.gz in the current working directory., (*24)

--source-type, -stype

The source type (e.g. local, dropbox, ftp). Defaults to local., (*25)

digipolis:push-package

vendor/bin/robo digipolis:push-package USER HOST PACKAGE [DESTINATION] [OPTIONS], (*26)

Arguments

USER

The user to connect to the host., (*27)

HOST

The host to connect to., (*28)

PACKAGE

The package (tar-file) to push., (*29)

DESTINATION

The destination folder on the server. Defaults to the home directory of the user., (*30)

Options

--password

The password to connect to the host., (*31)

--key-file

The private key file to connect to the host., (*32)

--port

The port to connect on. Defaults to 22., (*33)

--timeout

The timeout for the connection in seconds. Defaults to 10., (*34)

The Versions

05/07 2018

dev-master

9999999-dev

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

05/07 2018

0.1.7

0.1.7.0

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

05/07 2018

dev-develop

dev-develop

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

21/06 2018

0.1.6

0.1.6.0

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

29/11 2017

0.1.5

0.1.5.0

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

29/11 2017

0.1.4

0.1.4.0

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

19/09 2017

0.1.3

0.1.3.0

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

15/06 2017

0.1.2

0.1.2.0

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

09/03 2017

0.1.1

0.1.1.0

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

09/03 2017

0.1.0

0.1.0.0

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

03/03 2017

0.1.0-rc10

0.1.0.0-RC10

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

03/03 2017

0.1.0-rc9

0.1.0.0-RC9

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

03/03 2017

0.1.0-rc8

0.1.0.0-RC8

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

03/03 2017

0.1.0-rc7

0.1.0.0-RC7

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

03/03 2017

0.1.0-rc6

0.1.0.0-RC6

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

02/03 2017

0.1.0-rc5

0.1.0.0-RC5

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

28/02 2017

0.1.0-rc3

0.1.0.0-RC3

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

28/02 2017

0.1.0-rc4

0.1.0.0-RC4

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

24/02 2017

0.1.0-rc1

0.1.0.0-RC1

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

24/02 2017

0.1.0-rc2

0.1.0.0-RC2

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

17/02 2017

0.1.0-beta1

0.1.0.0-beta1

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

15/02 2017

0.1.0-alpha2

0.1.0.0-alpha2

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts

14/02 2017

0.1.0-alpha1

0.1.0.0-alpha1

Deploy tasks for Robo Task Runner

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dieter Blomme
by Jelle Sebreghts