Is it possible to restore from this backup? I would like to be able to ensure that we can always restore to a previous version in case something went wrong. Is this possible?
in the other half we show how to import data from an existing backup. If you save all the records, uploads, models and fields you should be always able to restore everything.
Soon we’ll launch out of beta the sandbox environments, and with that also a feature for automatic backups. If you want to have a look we can duplicate your project and enable the sandbox environments so that you can have a go!
If you have an external backup, you can use our CMA to map it back into your project, and if you have a forked environment from the environment you deleted something, you can use it to transfer back the data through the CMA, or just promote the environment all together.
If you do not have any form of backup:
Unfortunately the backup on our end is reserved only for internal disaster recovery, as a means of recovering data from user mistakes, we recommend using a forked environment as a backup, allowing for the data to always be preserved.
That forks weekly and daily the main environment into two distinct backup sandboxes that can be promoted (or just accessed for reference) in case of user error.
We also have a plugin that sends deleted records to a bin, where they can be restored with a single click in case of user error: Record bin - Plugins — DatoCMS
Additionally you can also externally export your whole dashboard (all assets + records) by running this simple script: Exporting data and backups — DatoCMS
let me explain my issue in more details, we have two different DATO projects, due to security restrictions, one for production and one for staging.
the thing is the contents in the production project is more up to date, so i would like to export all the schemes and contents and import them in a new env in our staging project.
is there any way to do this ? as i saw there was a feature in beta in the reply from mat_jack1
However, for content, we usually advise against transferring content between project, as it requires some scripting work to be done, to map the content of one project to another.
So, for schema, the way to go would be to use the tutorial above, but for content, using the REST API to fetch, then create records in the new project through a script is the only way to go unfortunately
And just to clarify, @idir.alileche, you can have both prod and staging as different environments within the same project. That way it should be easier to clone the primary to a new sandbox any time you need it, or to promote a sandbox to primary if you need to “restore” an old backup.
So I’m left wondering what the proper way to achieve this is. Do I have to clone the primary environment, write a script that compares my backup file to the cloned environment, noting what records to modify, create or delete and then write code to do that? That all seems fairly complicated to just restore a backup, is there a better way to achieve this that I’m missing? Can I just fully restore my backup content into an empty environment and then promote that?
If I am trying to create records that reference each other, how does that work? If an Article object has a related field, let’s say Categories, do I have to write my script in such a way that I create the categories first? So it would matter exactly how my data in the json file was structured or I’d have to make multiple passes to create certain objects first?
This is where I’m getting confused and thinking that surely there is a better way to restore from one of these backup files that you show us how to create.
@b.wyman it depends on what you’re trying to restore. If you make regular backups (like using this plugin, you can make nightlies: Automatic environment backups - Plugins — DatoCMS), then the easiest thing to do is to just promote one of the backup environments. That would be a “full” restore from that environment, meaning it would overwrite whatever was added to prod since that environment was initially made. You’d lose a day’s worth of content, yes, but the “restore” process itself would only take a second, since all you’re doing is marking one of the backups as the new primary env.
If you don’t want that data loss, then yes, I’m afraid you’ll have to manually write the script, diff the contents, and copy things over manually, keeping track of relationships in the process. I believe you’d have to create all the entities first and then make a separate call to update them to restore the links to the other records/media.
Yeah, that means a lot of tedious scripting It’s far from ideal, unfortunately. For most use cases, we suggest just using the environments instead and doing a full restore, because that’s much simpler. Sorry about that