# Can you duplicate a singleton?

**URL:** <https://discourse.getcockpit.com/t/can-you-duplicate-a-singleton/1663>\
**Category:** Uncategorized\
**Created:** [October 3, 2020, 8:41pm UTC](https://discourse.getcockpit.com/t/can-you-duplicate-a-singleton/1663 "2020-10-03T20:41:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![oboogy](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/oboogy/32/680_2.png) [@oboogy](https://discourse.getcockpit.com/u/oboogy)\
**Post date:** [October 3, 2020, 8:41pm UTC](https://discourse.getcockpit.com/t/can-you-duplicate-a-singleton/1663/1 "2020-10-03T20:41:55Z")

</div>

Is there a way to clone or duplicate a singleton structure like you can with a collection?

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [October 4, 2020, 10:24am UTC](https://discourse.getcockpit.com/t/can-you-duplicate-a-singleton/1663/2 "2020-10-04T10:24:11Z")

</div>

See:

> [@Duplicate singelton](https://discourse.getcockpit.com/t/duplicate-singelton/906/2):
>
> There is no easy method, yet. You can copy and paste the field definitions from /storage/singleton/old.singleton.php to /storage/singleton/new.singleton.php. Now the fields are cloned. If you want to clone the data, too, just get the data from the old one and save it to the new one. The PHP way: // get data from singleton "old" $data = $app-\>module('singletons')-\>getData('old'); // save data to "new" $app-\>module('singletons')-\>saveData('new', $data); Here is a simple way to save singleton…

---

<div class="post-metadata">

**Author:** ![oboogy](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/oboogy/32/680_2.png) [@oboogy](https://discourse.getcockpit.com/u/oboogy)\
**Post date:** [October 4, 2020, 2:19pm UTC](https://discourse.getcockpit.com/t/can-you-duplicate-a-singleton/1663/3 "2020-10-04T14:19:08Z")

</div>

Its unfortunate there’s no easy way because I’m having so much fun with singletons now but what a pain to keep making these fields over a d over.

I’ve tried duplicating the file from inside the singleton folder but the singleton doesn’t appear in the dashboard? Is there something else that needs to be done along side that?

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [October 4, 2020, 3:22pm UTC](https://discourse.getcockpit.com/t/can-you-duplicate-a-singleton/1663/4 "2020-10-04T15:22:26Z")

</div>

> [@oboogy](#):
>
> Is there something else that needs to be done along side that?

Did you change the name and the id in the copied singleton defintition file, too?

---

<div class="post-metadata">

**Author:** ![oboogy](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/oboogy/32/680_2.png) [@oboogy](https://discourse.getcockpit.com/u/oboogy)\
**Post date:** [October 4, 2020, 3:42pm UTC](https://discourse.getcockpit.com/t/can-you-duplicate-a-singleton/1663/5 "2020-10-04T15:42:17Z")

</div>

> Did you change the name and the id in the copied singleton defintition file, too?

Yes. It still doesn’t show in the dashboard. Would you have to also duplicate it somehow in the db? Doesn’t it store it somehwere beside just a php file?

---

<div class="post-metadata">

**Author:** ![oboogy](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/oboogy/32/680_2.png) [@oboogy](https://discourse.getcockpit.com/u/oboogy)\
**Post date:** [October 4, 2020, 3:44pm UTC](https://discourse.getcockpit.com/t/can-you-duplicate-a-singleton/1663/6 "2020-10-04T15:44:54Z")

</div>

Oh, it’s working now! When I renamed, at one point I missed keeping the .singleton one time and another time I had the name different than the saved id.

But is that really all it takes, so the data and structure is not saved in a db just this php file? That would be super easy.

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [October 5, 2020, 9:49am UTC](https://discourse.getcockpit.com/t/can-you-duplicate-a-singleton/1663/7 "2020-10-05T09:49:56Z")

</div>

The structures of collections and singletons are stored in php files. It’s that easy 🙂

The data/input of singletons is stored in the database. If you want to transfer the data, you have to copy the db files or export/import it.
