The promotion model assembles components to be promoted to your production server. When a promotion is stowed, the promotion model generates several build files within the sandbox environment that must be moved to the production environment when you are ready to promote your changes. The process of transferring these files from the sandbox to the production server is called staging. There are two main ways that build files can be staged:
Generally, option 1 is used provided your sandbox hosts an FTP server.
What Files Need to be Copied?
When you stow a promotion, the name of the promotion is used to derive the folder where the build files are stored. Here we see a set of 6 files that were generated when the fall_sale specification was stowed:
The names of all of the files end with the current date and time to reflect when the build was created. The first four files are always present. The transfer_private zip file will be generated if the build includes information to be copied to the private_data folders. The transfer_public file will be generated if the build includes assets to be copies to the public_html folders.
Copying the Files Manually
The main reason you might have to copy the build files manually is that your sandbox does not host an FTP server. For example, if your sandbox is a desktop computer some ISPs do not allow customers to open up port 21 to host an FTP server.
To copy the files manually, open Filezilla or some other FTP client and copy the folder containing the build files to your production server as shown here:
Make note of the fact that the name of the folder containing the build files in the sandbox is promotion (singular) whereas the name of the folder on your production server is promotions (plural). In the image above, since the fall_sale folder is not yet defined on the production server, this folder would need to be copied including all of its contents.
Automating the FTP Process
If your sandbox runs an FTP server, you can automate the FTP process so that the promotion program that runs on your production server (via page sysadmin/promotion_browse) automatically pulls the build files from your sandbox.
There are two methods by which the production server can obtain the FTP credentials required by the sandbox:
Note that both methods are very secure since the user id and password are always encrypted when being sent via the internet, even when using the http protocol. Also, the request, itself, is encrypted (or doubly encrypted if using https). Option 1 is a good idea if your sandbox accepts public http(s) requests especially if the sandbox supports multiple production servers since this allows you to save your sandbox user name and password in one place regardless of how many production servers utilize the sandbox server.
Defining Your Password on the Sandbox
If you are using option 1, you must add two lines to your sandbox config file (located in private_data/system/config). The lines will look something like this:
To generate the encrypted credentials visit your sandbox url https:\\genhelm.yoursandbox.com/?page=sysadmin/ftp_config. The first link on this page will let you generate the lines similar to the above code that you can paste into your sandbox config file. You will need to enter your unencrypted FTP user name and password and the page will generate the encrypted versions.
Defining Your Sandbox Password on your Production Server(s)
To define your sandbox password on your production server, you must create a PHP include file such as the following in your production environment:
This code needs to be named using whatever logical name you want to give your sandbox. For example, if you call this devbox1, the file will be named devbox1.inc and it must reside within the folder private_data/system/config/sandbox on your production server.
The code above is also generated by navigating to the page sysadmin/ftp_config. In this case, you choose the second link on the page. In your production environment you can run this from any website that is hosted on your production server to which you have a login. If you don't have a production website created yet, you can run this from the system subdomain as in:
You will need login access to system in order to load this page.
Alternatively, you can generate the required code on the sandbox provided you supply the server password associated with your production server. You will need to copy this from the existing config file within your production environment.
Note that the sandbox config file (located on your production server) is required even if you are storing the encrypted credentials on the sandbox itself. In such a case, the config file will look something like this:
With this configuration, the promotion function running in production will issue an https request to mysandbox.com in order obtain the sandbox credentials.
Normally, when the defined FTP user first establishes an FTP connection, the root directory should coincide with the sandbox's private data folder. In such a case, you do not need to include the code:
This code is needed if the default root directory is higher in the file path and is used to establish the path to the private_data folder.
If your sandbox does not host an FTP server, the config file might look like this:
In this case, you will need to manually FTP the build files to your production server.
Identifying the Sandboxes to your Production Server
The next step is to update your production config file (located in private_data/system/config) to point to the correct sandbox config file. The code you add will depend on how many sandboxes support the production server.
One Sandbox Only
If you only have one sandbox, simply add one line of code to the production config file such as the following:
The name you choose must agree with the name of the .inc file that you saved within private_data/system/config/sandbox but don't include the .inc extension in the set_sandbox parameter.
If your production server is supported by several sandboxes, the set_sandbox function will be passed an array of sandbox definitions as shown here:
In this case, the keys of the array reflect the site directories of various sites and the value of the array is the name of the sandbox to be used for the site. The special key '!default' will be used for sites whose site directories are not specifically listed.
It is also possible to override the name of the sandbox to be used for a specific site by using the site_settings model for the site as shown here:
For all sandbox names referenced, there must be a corresponding .inc file on you production server within the private_data/system/config/sandbox folder.