# Backup / restore in hosted server

**URL:** <https://openziti.discourse.group/t/backup-restore-in-hosted-server/1568>\
**Category:** Uncategorized\
**Created:** [August 28, 2023, 10:43am UTC](https://openziti.discourse.group/t/backup-restore-in-hosted-server/1568 "2023-08-28T10:43:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kashif](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/kashif/32/1197_2.png) [@kashif](https://openziti.discourse.group/u/kashif)\
**Post date:** [August 28, 2023, 10:43am UTC](https://openziti.discourse.group/t/backup-restore-in-hosted-server/1568/1 "2023-08-28T10:43:01Z")

</div>

Hi,  
Explored some stuff and I found that there is a backup/restore procedure for docker container. Is there a way to take backup for hosted server anywhere? In ZAC or via CLI?  
Thank you

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [August 28, 2023, 11:52am UTC](https://openziti.discourse.group/t/backup-restore-in-hosted-server/1568/2 "2023-08-28T11:52:09Z")

</div>

Hi @kashif,

To backup your OpenZiti network you should:

- backup the database by running this CLI command: `ziti edge db snapshot`. If you used the quickstart that will put a file into `$ZITI_HOME/db/` namded `ctrl.db-*`. Or, look at the controller's config file and find the `db:` setting. The backup is placed next to that file and has the current time appended in `YYYYMMDD-hhmmss` format. Example: `ctrl.db-20230828-114750`
- backup the PKI for the controller. If you ran the quickstart this will be `$ZITI_HOME/pki`. Backup the full folder. If not, you probably understand how to back your whole pki up. 🙂
- backup the controller config file at $ZITI\_HOME

---

<div class="post-metadata">

**Author:** ![kashif](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/kashif/32/1197_2.png) [@kashif](https://openziti.discourse.group/u/kashif)\
**Post date:** [August 28, 2023, 12:27pm UTC](https://openziti.discourse.group/t/backup-restore-in-hosted-server/1568/3 "2023-08-28T12:27:05Z")

</div>

> [@TheLumberjack](#):
>
> $ZITI\_HOME

Thank you again.

In the controller folder ($ZITI\_HOME | /root/.ziti/quickstart/openziti) you mean to take backup just yaml file or to take whole folder as a backup?

And restore procedure please.

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [August 28, 2023, 12:37pm UTC](https://openziti.discourse.group/t/backup-restore-in-hosted-server/1568/4 "2023-08-28T12:37:35Z")

</div>

I'd tell you to take JUST the `$ZITI_HOME/pki` folder, the controller's configuration file (If using "the host it anywhere" quickstart it'd be named: `$ZITI_HOME/$ZITI_NETWORK.yaml`) and the db snapshot. Oh and actually, you might want to also backup the systemd file at `/etc/systemd/system/ziti-controller.service`

We don't have this whole process documented at this time and I will admit that I have not tested this myself yet but here's the process that you should be able to use to restore:

- put back systemd unit file `/etc/systemd/system/ziti-controller.service`
- put back yaml file at `$ZITI_HOME/$ZITI_NETWORK.yaml`
- put pki directory back into `$ZITI_HOME/pki`
- put db back into `$ZITI_HOME/db/ctrl.db` (notice I renamed it, without the timestamp)
- enable the systemd unit file: `sudo systemctl enable --now ziti-controller`

---

<div class="post-metadata">

**Author:** ![kashif](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/kashif/32/1197_2.png) [@kashif](https://openziti.discourse.group/u/kashif)\
**Post date:** [August 29, 2023, 6:37am UTC](https://openziti.discourse.group/t/backup-restore-in-hosted-server/1568/5 "2023-08-29T06:37:17Z")

</div>

Thank you for your kind help.  
Will try it out soon.
