Export / Import Configuration Across Environments
This article describes the process and functions involved in transferring a site from one environment to the next.
Feature Overview
This article describes the process and functions involved in transferring a site from one environment to the next.
Assumptions
You ahve a site and are familiar with Umbraco. All functions are perfomed from within the Umbraco Backoffice.
Design Details
It is important to understand the building blocks that allows the import and export process to work. First of all, Umbraco stores all of the site configuration in a SQL database. This means every time you create a new page, or change a property on an existing page, the information is written to the database. In addition to this, we use a tool called uSync. uSync duplicates all of the configuration into xml files on the web server.
When you create a new page, Umbraco saves the page configuration to the database, and uSync saves the page configuration to an xml file. uSync has the ability to update the configuration in the database from the configuration in the file, as well as to update the configuration in the file from the contents of the database. It can also compare the two and show any differences. If you have a single site, the file and the database will pretty much always be in sync, but when we do an import to a different site, we override the uSync XML files, which then causes the database and the files to be different. using uSync we can then update the database from the new files, thus bringing our site into alignment with the files. This forms the basis for our export / import process.
uSync in detail
uSync has a few quirky bits to it that needs to be well understood.
uSync keeps track of page deletions as well, and will create an file with a delete instruction for a page if you remove it. This can be handy if you need to remove the same page in your target environment.
uSync also has a "Clean Export" function. This will delete all the xml files, and recreate them from the database. This means your delete page markers will be removed, but it also ensures the the files and the database are 100% in sync. This is good for when we need to export to a fresh environment.
uSync separates updates into content and settings. This is a very handy feature. Settings are typically the things we would change in product, for instance creating a new page template (e.g. dynamics form), adding functionality like configuration options on lists and forms, etc. Content includes the actual pages, all their properties, and media entries like scripts and images, which is what you would typically be changing.
uSync does not do the following:
- It keeps track of media objects in the database, but not the physical files behind them. To explain this: When you upload an image into Umbraco's content area, 2 things happen: Umbraco creates a media entry in the database to remember that it has that item, and it saves the file somewhere. The file is either saved on the web site, or in blob storage, depending on your configuration. The file is not stored in the database. This means that uSync creates a file to represent the media entry in the database, but it does not have the file itself. If you import uSync alone to a new environment, the media item will appear in Umbraco, but without a file.
- uSync does not include page permissions in its files. This is where you set a page to only be visible if the web site user (member / CRM Contact that logs into the front end) has a specific role.
- uSync does not transfer any web site specific files, like template code and custom css files
To overcome these shortcomings, we have created the Klevr import / export process. This process is similar to uSync in that it would generate a xml file to represent the page permissions, and include selected page templates and custom css and media files, as well as all the uSync xml files in its export.
Standard process
By understanding the information above, we can derive that a standard process to transfer your site from one environment to the next would be:
Configure your development site to customer requirements. uSync will create the XML files in the background to represent all your changes.
Ensure all your pages are published and your content recycle bin is empty.
Upload your media items.
Optionally change template code or create your own templates. Keep track of which files you have changed.
Go to uSync, and do a report on everything to ensure the uSync files still match the Umbraco database. If it doesn't, you either have to update the databse from the uSync files, or make a change to the relevant item in umbraco to trigger uSync to recreate the file, or do a uSync clean export, although this will remove any page delete markers as explained earlier.
Go to the klevr Setting page, to the export area. If you have changed any templates, expand the templates area and select the templates you have changed. It is recommended not to just include all templates, as these templates are mostly maintained in the klevr product, and will be updated during site upgrades. if you then replace them with an old copy from a previous export, you might experience unexplained bugs.
Select the custometheme.css file if you have made changes to it.
Click export. The zip file contains all the uSync files, and the physical media and template files you have selected. For advanced users and specific complex situations, you could even extract the zip file and modify the files inside it, or remove file that you may not want to import, but most of the time this is not neccesary,
Log in to your target site. Ensure it is on the same klevr version as the source site, especially if you have templates included.
Ensure the content area recycle bin is empty.
Go to the klevr Settings area to the import section. Select the downloaded zip file, and optionally select "clean import". What this will do is first delete all uSync files, and then extract the uSync files from the uploaded zip file to the uSync folder. otherwise it will only replace and add files to the uSync folder. There's not much difference between these two, unless you have made changes to your target environment manually (e.g. create or delete pages in the target environment, which would then have associated uSync files).
Run a uSync report to see if the expected changes are detected by uSync. Typically all your changes should only be in the content area, so by running a report on settings, you should expect to see no changes, and can review any that is there to decide if you need to import them or not. Run a compare on content to see all the changes that it will apply to content
Once you are happy with the intended changes, run the uSync import. Again typically only and import on content is required, but you may have some settings changes too, so you could run a full import if this is the case.
Return to the klevr setting area and click the "Apply post uSync changes". This will appy the page permissions to the pages that is now created by the uSync import, and upload the physical media and template files to the correct location.
Refresh the umbraco backoffice, and check that your expected changes are applied.
Klevr table permissions are not exported and imported as part of this process, so thse need to be done separately. Go to the klevr table permissions configuration screen on the source site, and click export. Then navigate to table permissions screen on the target site, select the downloaded file, and click import. Ensure the permissions and number of rows match. It may be neccesary to delete all the permissions and import again if they do not match completely.
Alternate Flows
In some cases, a site might have gotten very out of sync with another site. E.g. someone inadvertently changed pages in the target site instead of in the source site, or a lot of pages was deleted and recreated. In a situration like this it may be a good idea to "reset" the target site by deleting all of the content, empty the recycle bin, and do a "clean import" in the klevr settings area. Then run through the process above to import uSync and apply the post import changes.
Last updated on