Deployment management for Drupal websites (and others with similar structures) that makes database and user file migration between production, development and staging extremly fast and simple.
The premise of this utililty assumes that you will manage the codebase of the project with source control such as Git. Loft deploy adds the ability to pull the database and/or the user files (files not in your version control) from production to local, and push or pull the database and user files between local and staging.
While it is not limited to Drupal, it does assume this type of tri-component scenario (codebase, database, user files). If you have neither a database nor user files, you would be wise not to use this tool as it adds complexity without utility. With only a codebase to manage, simply use Git.
Loft Deploy does not intend to replace codebase management with version control systems such as Git. Such systems should continue to be used in tandem with Loft Deploy.
Fetching grabs the remote assets and caches them locally, but does not alter your local environment. You have to reset to do that. Cached assets can be found in the .loft_deploy folder.
Uses the cached remote assets from the last fetch to alter your local environment. Saves you download time if you are doing frequent resets to test update scripts or something, where you need to continusously reset to match the production database, for example.
A combination that will do a fetch and reset in one command.
[ PRODUCTION ]
|
\|/
'
[ LOCAL ] <--> [ STAGING ]
The production database is always considered the "origin"--that is to say it is the master of the database component of any group of production/local/staging servers. When developing locally you should be making your database changes directly on the production database (or in an update script of a module) and then pulling using loft_deploy, but never will you push a local or staging database to production. Before local development you will need to refresh your local database and you do that with Loft Deploy loft_deploy pull -d
.
After you have completed local development you may want to push to a staging server for client review. You will use Loft Deploy loft_deploy push -d
to push your local database to the staging server.
User files (i.e. sites/default/files), which are too dynamic to include in version control, also originate and must be changed on the production server. Just like the database, the dev and staging environments need to be brought to match production at times. Loft Deploy will do this using loft_deploy pull -f
. You may still use Loft Deploy this when you do not have a user files directory, just omit any config variables referencing files
.
For more information see user files.
By default fetch
, reset
and pull
will grab from production. In order to perform these functions using staging as the source you will need to pass the --staging
flag like this:
loft_deploy pull --staging
loft_deploy fetch --staging
loft_deploy reset --staging
The command push
is always directed at the staging server.
USE AT YOUR OWN RISK AS IMPROPER CONFIGURATION CAN RESULT IN DESTRUCTION OF DATABASE CONTENT AND FILES.
The following assumptions are made about your project:
If these assumptions are not true then this package may be less useful to you.
loft_deploy init dev
and loft_deploy init prod
and maybe loft_deploy init staging
on each of the appropriate servers.sites/[sitename]
and install it there run loft_deploy init
there. You will then be restricted to running loft deploy oeprations to /sites/[sitename]
and any child directories.local_role
. Setting this correctly ensures certain access checks, which may help to prevent damaging your production environment.local_role
to: dev, prod or staging.loft_deploy configtest
.Finally, test each environment before first use. You may run 'configtest' at any time in the future as well.
$ loft_deploy configtest
GOTCHA!!! It is crucial to realize that the configuration for these needs to be created on the same environmnet as the database. Meaning, if you are wanting to exclude files from the production database, when pulling from a local dev environment, the files described below MUST be created on the production server config files.
sql/db_tables_no_data
Scenario: You are working on a Drupal site and you do not want to export the contents of the cache
or cache_bootstrap
tables. Here's how to configure Loft Deploy to do this:
In that file add the following (one table per line):
cache
cache_bootstrap
Now only the table structure and not the data will be exported.
cache
tables?Yes this is supported and is done like this:
.sql
.In that file add the sql command to select all cache tables, e.g.,
SELECT table_name FROM information_schema.tables WHERE table_schema = '$local_db_name' AND table_name LIKE 'cache%';
Notice the use of $local_db_name, which will be dynamically replaced with the configured values for the database table.
Here are the dynamic component(s) available:
variable |
---|
$local_db_name |
After installed and configured type: loft_deploy help
for available commands; you may also access the help by simply typing loft_develop