# Settings export/import

**URL:** https://meta.discourse.org/t/settings-export-import/174480
**Category:** Bug
**Created:** [December 29, 2020, 8:40am UTC](https://meta.discourse.org/t/settings-export-import/174480 "2020-12-29T08:40:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [December 29, 2020, 8:40am UTC](https://meta.discourse.org/t/settings-export-import/174480/1 "2020-12-29T08:40:59Z")

</div>

Nothing really big, but I ran into a small issue using `site_settings:import` and it bit me _hard_.  
There is an easy 'n ugly workaround (run the rake task twice) but this is typically something that is being run unattended so I did not see the error at first.

(Part of) exported settings file (`site_settings:export`)

```
sso_overrides_email: 'true'
email_editable: 'false'

```

Importing that file into another forum:

```
ERROR: sso_overrides_email: You must disable 'email editable' before enabling this setting.
Changed email_editable FROM: t TO: false

```

The second run does of course pick up the setting:

`Changed sso_overrides_email FROM: f TO: true`

Possible solutions:

- Live with it and just run the import rake task twice
- Export settings in `updated_at` order
- Have the rake task run the import twice
- Disable this kind of checks when importing from a file

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [January 2, 2021, 10:04am UTC](https://meta.discourse.org/t/settings-export-import/174480/2 "2021-01-02T10:04:36Z")

</div>

Which solution do you think makes the most sense?

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [January 2, 2021, 11:58am UTC](https://meta.discourse.org/t/settings-export-import/174480/3 "2021-01-02T11:58:48Z")

</div>

I’m not sure.

> [@RGJ](#):
>
> Export settings in `updated_at` order

will work, does not take too much of an effort, and is most logical, but will still fail if additional restrictions are implemented after the settings were made.

> [@RGJ](#):
>
> Live with it and just run the import rake task ~~twice~~ until no more errors happen

will work but will not make sense to people,

> [@RGJ](#):
>
> Have the rake task run the import ~~twice~~ until no more errors happen

is really ugly, but works

> [@RGJ](#):
>
> Disable this kind of checks when importing from a file

might introduce all kinds of nasty things and might take a lot of effort.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 5, 2021, 12:14am UTC](https://meta.discourse.org/t/settings-export-import/174480/4 "2021-01-05T00:14:55Z")

</div>

> [@RGJ](#):
>
> Export settings in `updated_at` order

I don’t think this will work.

Simplest to me is just running this twice and if it errors the second time around bail out.

That said, it is not as trivial as “running twice”

1. You run it the first time, catching errors on any particular setting you set
2. Second time you just run it in a batch and bail out if anything fails

If we are already handling this mess we got to handle cases where there are multiple dependencies going on.

There is also the question of clean rollback, so this is not a trivial task at all.
