# What is the best backup approach?

**URL:** <https://community.kinsta.com/t/what-is-the-best-backup-approach/517>\
**Category:** Application Support\
**Created:** [March 22, 2021, 9:17am UTC](https://community.kinsta.com/t/what-is-the-best-backup-approach/517 "2021-03-22T09:17:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![GoldyOnline](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@GoldyOnline](https://community.kinsta.com/u/GoldyOnline)\
**Post date:** [March 22, 2021, 9:17am UTC](https://community.kinsta.com/t/what-is-the-best-backup-approach/517/1 "2021-03-22T09:17:05Z")

</div>

I’ve started using DevKinsta on Windows 10 and have downloaded one of my live Kinsta-hosted websites and I’m now developing this website further on my local machine. So far it works fine but I’m wondering what the easiest approach is for making sure I always have recent backups of my local work.

I do have incremental backups for the whole Windows machine in this case but I would like to add something that only does backups of my local web development work, which can then also easily be restored if data is lost or if I mess something up:)  
For just the files I suppose I could do a continuous sync of the website files with Dropbox but that seems like a bad idea performance-wise.

Any suggestions for an elegant and efficient solution which keeps backups of all files and databases while not (too) negatively impacting performance?

---

<div class="post-metadata">

**Author:** ![michael](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/michael/32/31_2.png) [@michael](https://community.kinsta.com/u/michael)\
**Post date:** [March 22, 2021, 4:27pm UTC](https://community.kinsta.com/t/what-is-the-best-backup-approach/517/2 "2021-03-22T16:27:54Z")

</div>

Welcome to DevKinsta @GoldyOnline ! I’m happy to help.

Depending on your experience with Docker, you can find several resources on Google for creating a Docker backup. We don’t have a personal recommendation on backing up a Docker container but [here’s one I did find](https://bobcares.com/blog/docker-backup/).

> [@GoldyOnline](#):
>
> For just the files I suppose I could do a continuous sync of the website files with Dropbox but that seems like a bad idea performance-wise.

Not a bad idea at all. The only thing to note is that it won’t backup the database. It shouldn’t affect the performance of the website itself either.

Let me know which direction you end up with.

---

<div class="post-metadata">

**Author:** ![GoldyOnline](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@GoldyOnline](https://community.kinsta.com/u/GoldyOnline)\
**Post date:** [March 23, 2021, 1:12pm UTC](https://community.kinsta.com/t/what-is-the-best-backup-approach/517/3 "2021-03-23T13:12:27Z")

</div>

Hi @michael  
Thanks for the feedback. For the files I might just go with Dropbox sync as you are saying it shouldn’t impact performance.  
For the db I think a docker container backup (and restore) sounds good. I just did some reading about it and tried it out but I’m running into some issues.

First of all, I wasn’t entirely sure which container to backup to make sure I backup any database changes/updates. I assumed this is the “devkinsta\_db” container (which is running the mariadb:10.5.5 image), is that correct?

I can make a snapshot of it using this command in Windows Powershell:  
docker commit -p devkinsta\_db devkinsta\_db\_backup

I can save it to the drive of my Windows machine for example then using:  
docker save -o C:\Temp\devkinsta\_db\_backup.tar devkinsta\_db\_backup

After that, I got stuck though when trying a restore. First, I stopped and removed the current container using:  
docker stop devkinsta\_db  
docker rm devkinsta\_db

Then I wanted to run the container again from my “backup image”. (in reality you might need to restore the image first from the .tar file but I skipped that step for now as a first test)

I tried the following, to run it detached and with the correct container name:  
docker run -d --name devkinsta\_db devkinsta\_db\_backup

Which didn’t work in the sense that the local test website was not loading after that and returning an error page related to no connection to mysql/mariadb.

I thought the issue might be in the port config and I tried also:  
docker run -d --name devkinsta\_db devkinsta\_db\_backup -p 0.0.0.0:15100:3306/tcp

which also didn’t work, with this latter command it seemed that the container didn’t even start properly as it doesn’t show when using:  
docker ps

After that I also tried simply to close DevKinsta after removing the devkinsta\_db container via Powershell, and then restarting DevKinsta after that. It then starts/runs automatically the devkinsta\_db container again and the local website is loading again. However, it is loading including my most recent change, which was a simple update in one post in Wordpress to see if I could restore to the state of the db from before I made that change.

My questions are:

1. Is taking a snapshot of the “devkinsta\_db” container and restoring it the right approach to backup and restore the database?
2. What is the correct run command to properly run the container when restoring from a backup image?
3. Anything else that I’m doing wrong?

---

<div class="post-metadata">

**Author:** ![michael](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/michael/32/31_2.png) [@michael](https://community.kinsta.com/u/michael)\
**Post date:** [March 23, 2021, 4:11pm UTC](https://community.kinsta.com/t/what-is-the-best-backup-approach/517/4 "2021-03-23T16:11:58Z")

</div>

Hi @GoldyOnline . It may be best to backup the database by itself rather than the entire container. Adminer can be used to produce an export. It’s the Database Manager button when viewing a site on DevKinsta.

 ![Screen Shot on 2021-03-23 at 12:08:36](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/1X/7eb6876a41207a84ab97ff3caf2d7701825d1eaf.jpeg)

From there, you can do an export here:

 ![Screen Shot on 2021-03-23 at 12:09:46](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/1X/8596e1281a1077c118d5a7e6e9f286ee3d95fa38.png)

This backup will be better to hold onto as it can be used to restore onto any platform and not an entire Docker container.

---

<div class="post-metadata">

**Author:** ![GoldyOnline](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@GoldyOnline](https://community.kinsta.com/u/GoldyOnline)\
**Post date:** [March 23, 2021, 5:04pm UTC](https://community.kinsta.com/t/what-is-the-best-backup-approach/517/5 "2021-03-23T17:04:15Z")

</div>

Hi @michael

Thanks for the feedback but I was hoping to make it work with a Docker container backup, as per your own suggestion. It’s an elegant solution in my opinion and it would allow going back to a previous state/version with a few simple clicks or commands.

Can you provide some feedback on my questions related to that please as well?

---

<div class="post-metadata">

**Author:** ![michael](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/michael/32/31_2.png) [@michael](https://community.kinsta.com/u/michael)\
**Post date:** [March 23, 2021, 7:31pm UTC](https://community.kinsta.com/t/what-is-the-best-backup-approach/517/6 "2021-03-23T19:31:31Z")

</div>

> [@GoldyOnline](#):
>
> Thanks for the feedback but I was hoping to make it work with a Docker container backup, as per your own suggestion. It’s an elegant solution in my opinion and it would allow going back to a previous state/version with a few simple clicks or commands.

While it does work, I don’t believe it’s as elegant nor as portable as the Adminer straight sql backup method which can then be restored anywhere. It’s best to have DevKinsta create the container so any updates on DevKinsta can also occur on the containers.

> [@GoldyOnline](#):
>
> Is taking a snapshot of the “devkinsta\_db” container and restoring it the right approach to backup and restore the database?

It’s an approach, though not sure if it’s the right approach if the only information you require is of the database itself. It’s not the easiest approach.

> [@GoldyOnline](#):
>
> What is the correct run command to properly run the container when restoring from a backup image?

_docker container run_ should do it.

---

<div class="post-metadata">

**Author:** ![GoldyOnline](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@GoldyOnline](https://community.kinsta.com/u/GoldyOnline)\
**Post date:** [March 24, 2021, 6:10pm UTC](https://community.kinsta.com/t/what-is-the-best-backup-approach/517/7 "2021-03-24T18:10:17Z")

</div>

Thanks for the further comments. I do understand the argument regarding keeping the backup portable, however, for my needs this is not important as I’m just looking to backup and restore to the same environment.  
Having said that, I appreciate your suggestions and maybe I will implement a mysql export, but then preferably an automated one (using an extra tool I guess) rather than manual, and as far as I’ve seen so far with Adminer I can’t do it automated.

In the meantime though I found a solution for backup and restore of the data of the container itself. It turns out that the devkinsta\_db container is using a volume mount, which means that the data persists even if the container is removed. So restoring just the container is not going to do much at all as the data is not in the container itself.

In Windows 10 the data of the container can be found here (paste the path in explorer):  
\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\devkinsta\_db\_data

I have tested backup and restore of the full content of this folder via Windows and this seems to work fine. When making a change in the db and then restoring the data (from before the change) I get back a working environment with the old (unchanged) data.  
And this is of course also something that can be automated easily.  
NOTE: the backup and restore steps should be done when the container is not running.

Having read your answers I’m not sure if you approve of the above approach but I thought I’d share it here as it does answer some of my initial questions and it does seem to work fine so far.

---

<div class="post-metadata">

**Author:** ![michael](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/michael/32/31_2.png) [@michael](https://community.kinsta.com/u/michael)\
**Post date:** [March 24, 2021, 11:18pm UTC](https://community.kinsta.com/t/what-is-the-best-backup-approach/517/8 "2021-03-24T23:18:33Z")

</div>

I’m glad that works for you @GoldyOnline and appreciate you sharing with everyone else here!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/8/80f8c4e56fecc02327a0964e6bf63a716483529f.png) [@system](https://community.kinsta.com/u/system)\
**Post date:** [March 27, 2021, 11:19pm UTC](https://community.kinsta.com/t/what-is-the-best-backup-approach/517/9 "2021-03-27T23:19:20Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
