Giter Site home page Giter Site logo

luya-module-exporter's Introduction

LUYA EXPORTER MODULE

This module will not recieve any updates in future and will not release in a stable version as its not recomend to use, use the luya admin proxy instead!

How to use luya proxy instead: https://luya.io/guide/concept-depandsync#sync

The exporter module allowss you to easily download the full database and storage data from a project for a local import and thus, to setup a state of a website at a given time.

Installation

Add the exporter module to your composer.json:

"luyadev/luya-module-exporter" : "1.0.0-RC4",

Set up you your application configuration as follows :

'modules' => [
    // ...
    'exporter' => [
        'class' => 'luya\exporter\Module',
        'downloadPassword' => 'EnterYourSecureRandomToken',
    ],
]

And finally run the ./vendor/bin/luya migrate and ./vendor/bin/luya import commands.

Using the exporter module

Now you can install a cronjob or run the command when doing deployment to prepare the download:

./vendor/bin/luya exporter/export

In order to download the above created files, just go into:

https://example.com/exporter?p=EnterYourSecureRandomToken and your zip will be downloaded.

Attention! HTTP sniffers can read your plain token.

Importing from a remote host

To import a database from a remote host, you can use this command:

./vendor/bin/luya exporter/database/remote-replace-local "mysql:host=localhost;dbname=REMOTE_DB_NAME" "USERNAME" "PASSWORD"

Attention! This command will drop all tables in your current database and replace them with the remote export.

To use this in a context where you aren't able to process user inputs (chained remote batch processing like in a deployer task) you can disable the security confirmation by adding the parameter --interactive=0. Obviously, this should be used with extreme caution to prevent any unwanted data losses.

For your safety there will be an automatically created database backup of the local db. The backup can be found in the local temporary system directory - the file name resembles like this: uniqid() . '-BACKUP-'.time()

Using exporter as a deployer task

When using the LUYA deployer you may want to add the remote replace local command as a task and execute them when deploying the prep environment, here an example of what this could look like, you will find more information in the luya deployer docs:

task('deploy:importProdDb', function() {
    cd('{{release_path}}');
    run('./vendor/bin/luya exporter/database/remote-replace-local "mysql:host=localhost;dbname=prod_database" "USER" "PASSWORD" --interactive=0');
})->onlyOn('prep');

after('deploy:luya', 'deploy:importProdDb');

luya-module-exporter's People

Contributors

jdl747 avatar martinpetrasch avatar nadar avatar samdark avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.