Transfer data to and from a Dedicated Gen 2 cluster

Transferring data to and from a Dedicated Gen 2 cluster slightly differs from the process on the Grid.

Back up your files 

Platform.sh automatically creates backups of the Staging and Production environments of a Dedicated Gen 2 cluster every six hours. These are only useful to fully restore an environment and are managed by the support team.

You can make a manual local backup yourself by downloading data from your environment to your local system by running the following command:

platform scp --project <PROJECT_ID> --environment <ENVIRONMENT> -r remote:<DIRECTORY_TO_SYNCHRONIZE> <LOCAL_DIRECTORY>

This command copies all files from the <DIRECTORY_TO_SYNCHRONIZE> in the environment you want to back up to your <LOCAL_DIRECTORY>. Before running the command, make sure that you don’t overwrite local data (or do a backup first).

Back up your database 

To back up your database, adapt and run the following command on your local computer:

platform db:dump --gzip --project <PROJECT_ID> --environment <ENVIRONMENT> 

For more backup options and examples, see how to export data from an SQL database.

Synchronize files from Development to Staging/Production 

To transfer data into either the Staging or Production environment, download data from your Development environment to your local system and from there to your Production/Staging environment.

  1. To download data from your Development environment to your local system, adapt the following command:

    platform scp --project <PROJECT_ID> --environment <DEVELOPMENT_ENVIRONMENT> -r remote:<DIRECTORY_TO_SYNCHRONIZE> <LOCAL_DIRECTORY>
  2. To copy the local directory to the remote Staging/Production mount, adapt the following command:

    platform scp --project <PROJECT_ID> --environment <TARGET_ENVIRONMENT> -r <LOCAL_DIRECTORY> remote:<DIRECTORY_TO_SYNCHRONIZE>

Synchronize a database from Development to Staging/Production 

To synchronize a database into either the Staging or Production environment, export the database from your Development environment to your local system and from there to your Staging/Production environment.

To synchronize your database:

  1. Export the Development database to your local computer:

    platform db:dump --project <PROJECT_ID> --environment <DEVELOPMENT_ENVIRONMENT> --file=dump.sql

    For more backup options and examples, see how to export data from an SQL database.

  2. Import the Development database dump file into the remote Staging/Production database:

    platform sql --project <PROJECT_ID> --environment <TARGET_ENVIRONMENT> < dump.sql

What’s next? 

For more granular connection options, see SSH connection details.