[GUIDE] backup and recover Portainer and docker apps

Introduce yourself to us and other members here, or share your own product reviews, suggestions, and tips and tricks of using QNAP products.
Post Reply
User avatar
Moogle Stiltzkin
Guru
Posts: 11445
Joined: Thu Dec 04, 2008 12:21 am
Location: Around the world....
Contact:

[GUIDE] backup and recover Portainer and docker apps

Post by Moogle Stiltzkin »

Image

I had recently encountered a catastrophic mess with docker. the set static ip in cs v3 no longer worked and it was buggy (it had previously worked fine before). it was probably my own fault for messing with some settings i shouldn't have. To recover i had to reinitialize the QNAP nas and start from scratch.



i will walk through the process how i backup and recovered (everything tested and verified by myself Image)

If you have a better solution plz share. I'm just sharing my own experience and hurdles so u can do the same or do better :wink:

it's for those wondering what to do if they need to backup and restore their docker apps after reinitializing their nas.


If i made any mistakes or overlooked something, feel free to provide correction, thxImage


The setup i am using fyi is

1. i am using container station v3 beta to install portainer (stable version for cs is v2)
2. i setup my docker apps using portainer using docker compose (custom templates/stacks)

So this guide will be based around the setup i am using.
Last edited by Moogle Stiltzkin on Fri Dec 09, 2022 7:07 pm, edited 5 times in total.
NAS
[Main Server] QNAP TS-877 (QTS) w. 4tb [ 3x HGST Deskstar NAS & 1x WD RED NAS ] EXT4 Raid5 & 2 x m.2 SATA Samsung 850 Evo raid1 +16gb ddr4 Crucial+ QWA-AC2600 wireless+QXP PCIE
[Backup] QNAP TS-653A (Truenas Core) w. 4x 2TB Samsung F3 (HD203WI) RaidZ1 ZFS + 8gb ddr3 Crucial
[^] QNAP TL-D400S 2x 4TB WD Red Nas (WD40EFRX) 2x 4TB Seagate Ironwolf, Raid5
[^] QNAP TS-509 Pro w. 4x 1TB WD RE3 (WD1002FBYS) EXT4 Raid5
[^] QNAP TS-253D (Truenas Scale)
[Mobile NAS] TBS-453DX w. 2x Crucial MX500 500gb EXT4 raid1

Network
Qotom Pfsense|100mbps FTTH | Win11, Ryzen 5600X Desktop (1x2tb Crucial P50 Plus M.2 SSD, 1x 8tb seagate Ironwolf,1x 4tb HGST Ultrastar 7K4000)


Resources
[Review] Moogle's QNAP experience
[Review] Moogle's TS-877 review
https://www.patreon.com/mooglestiltzkin
User avatar
Moogle Stiltzkin
Guru
Posts: 11445
Joined: Thu Dec 04, 2008 12:21 am
Location: Around the world....
Contact:

Re: [GUIDE] backup and recover Portainer station and docker apps

Post by Moogle Stiltzkin »

How to reset nas (THIS DELETES your DATA. BACKUP FIRST)

https://www.qnap.com/en-us/how-to/faq/a ... -explained



firstly, make sure you backup to a separate storage device.

make sure i'm on the latest stable firmware first. also make sure u have the qfinder app installed on your desktop client pc.

then factory reset. reinitialize.

for hdd raid, remove pool/volume. my ssd was used as a pair raid1 volume (for the system). remove the pool/volume for this. then do a ssd erase from within qts as well. this wipes out the previous setup on the SSD (system)

reinitialize again.

qfinder will detect and ask for smart install for an uninitialized NAS, click yes. then follow through setup process for setting a new nas (the first volume setup will be used for the system fyi.

default password for the QTS/QUTS HERO admin web UI is the 1st mac address (find this from qfinder). usually it will be listed in qfinder or the sticker on your nas

so if you want to setup system on ssd, set that up first. e.g. i had 2 ssds so i setup a static volume using 2 ssds in raid1 (volume1). Next i setup the 4hard drives as thick volume (volume2) in a pool.).

use hybridbackupsync to recover from backup (my backup was a tl-d400s)
*only reset/reinitialize NAS if you have to. Don't simply do it if there is no reason for it :)
Last edited by Moogle Stiltzkin on Fri Dec 09, 2022 5:05 pm, edited 1 time in total.
NAS
[Main Server] QNAP TS-877 (QTS) w. 4tb [ 3x HGST Deskstar NAS & 1x WD RED NAS ] EXT4 Raid5 & 2 x m.2 SATA Samsung 850 Evo raid1 +16gb ddr4 Crucial+ QWA-AC2600 wireless+QXP PCIE
[Backup] QNAP TS-653A (Truenas Core) w. 4x 2TB Samsung F3 (HD203WI) RaidZ1 ZFS + 8gb ddr3 Crucial
[^] QNAP TL-D400S 2x 4TB WD Red Nas (WD40EFRX) 2x 4TB Seagate Ironwolf, Raid5
[^] QNAP TS-509 Pro w. 4x 1TB WD RE3 (WD1002FBYS) EXT4 Raid5
[^] QNAP TS-253D (Truenas Scale)
[Mobile NAS] TBS-453DX w. 2x Crucial MX500 500gb EXT4 raid1

Network
Qotom Pfsense|100mbps FTTH | Win11, Ryzen 5600X Desktop (1x2tb Crucial P50 Plus M.2 SSD, 1x 8tb seagate Ironwolf,1x 4tb HGST Ultrastar 7K4000)


Resources
[Review] Moogle's QNAP experience
[Review] Moogle's TS-877 review
https://www.patreon.com/mooglestiltzkin
User avatar
Moogle Stiltzkin
Guru
Posts: 11445
Joined: Thu Dec 04, 2008 12:21 am
Location: Around the world....
Contact:

Re: [GUIDE] backup and recover Portainer station and docker apps

Post by Moogle Stiltzkin »

Ok, this part explains how to backup your dockers and to restore them after a reinitialize of your QNAP NAS.

For example, my dockers were setup using portainer. But portainer was setup using container station (i used the v3 which is a beta).

The docker apps i setup all had a persistent storage pointing to a specific folder. This is so whenever i update the docker apps, the configs and data for the app persist. This is what we need to backup.

just an example of what a persistent storage location would look like

Code: Select all

/share/Container/linuxserver-unifi/

Code: Select all

/share/Container/portainer-ce/

Code: Select all

/share/Container/dashy/

So i backup the persistent folders using hybrid backup sync. I didn't backup the containerstation-data folder, so i don't know if this can be recovered in that way or not (you can test it yourself and let us know).


then after finished reinitializing the qnap nas, install back container station (use v2 stable or v3 beta, up to you).

then install back portainer using container station. I posted a guide how to do this
viewtopic.php?f=45&t=168772&p=834129#p834129


Next, spin up portainer

Code: Select all

http://nas ip:9000

your previous portainer config should still work. so login.


then from here i see that the docker apps are all missing. But the custom templates and stacks are all there.

The stacks show it's running, but it's not. So what i did here was, stop the stack, then start it again. If that doesn't show the app in container (in portainer), then just redeploy the stack or just edit/recreate the docker app in container.

I tested this with dashy docker compose, and my dashy worked. In my docker compose it already pointed to the persistent folder, so all my dashy docker app settings were same as before.


What this means is i successfully backed up and recovered my docker app in portainer.



So in summary, what did we learn here, what to do to backup your docker apps? (at least in this setup i'm using as an example) and restore?

1. whenever installing dockers, ideally set a folder location for the config for that app to be persistent.
2. backup that persistent folder location
3. highly recommended to use docker compose and save custom templates. And deploy stacks. So this will make redeploying easy. And as i've shown, these templates of docker compose for your apps can be recoverable as i've proven.
4. the docker apps after recovery will show active (but they are not). So you have to manually restart them (i had to stop/start), for the docker app to work again.
5. If for some reason you felt the app is not working correctly, you can remove the container, then redeploy the stack or. or just edit/recreate from container.
6. careful when messing around with portainer. I removed qnet network to test, and this broke static ips when setting up using container station. So don't make the same mistake i did, otherwise you will have to reset your nas as well (took me 1-2 days to get everything setup back again :( )


Hopefully this helped someone else, if you are wondering how to backup your docker apps, and how to restore them :D
NAS
[Main Server] QNAP TS-877 (QTS) w. 4tb [ 3x HGST Deskstar NAS & 1x WD RED NAS ] EXT4 Raid5 & 2 x m.2 SATA Samsung 850 Evo raid1 +16gb ddr4 Crucial+ QWA-AC2600 wireless+QXP PCIE
[Backup] QNAP TS-653A (Truenas Core) w. 4x 2TB Samsung F3 (HD203WI) RaidZ1 ZFS + 8gb ddr3 Crucial
[^] QNAP TL-D400S 2x 4TB WD Red Nas (WD40EFRX) 2x 4TB Seagate Ironwolf, Raid5
[^] QNAP TS-509 Pro w. 4x 1TB WD RE3 (WD1002FBYS) EXT4 Raid5
[^] QNAP TS-253D (Truenas Scale)
[Mobile NAS] TBS-453DX w. 2x Crucial MX500 500gb EXT4 raid1

Network
Qotom Pfsense|100mbps FTTH | Win11, Ryzen 5600X Desktop (1x2tb Crucial P50 Plus M.2 SSD, 1x 8tb seagate Ironwolf,1x 4tb HGST Ultrastar 7K4000)


Resources
[Review] Moogle's QNAP experience
[Review] Moogle's TS-877 review
https://www.patreon.com/mooglestiltzkin
User avatar
Moogle Stiltzkin
Guru
Posts: 11445
Joined: Thu Dec 04, 2008 12:21 am
Location: Around the world....
Contact:

Re: [GUIDE] backup and recover Portainer station and docker apps

Post by Moogle Stiltzkin »

and if anyone cares to know, reinitializing my nas got my container station static ips working again.

now i managed to get unifi controller docker setup (i had to do it using cs v3, because i don't know how to set a static using portainer), and it works flawlessly.

Now i just need to not mess with anything because it works :D (previously i was doing a lot of testing so at one point i mess something up which ended in catastrophe. will avoid that mistake xd)
NAS
[Main Server] QNAP TS-877 (QTS) w. 4tb [ 3x HGST Deskstar NAS & 1x WD RED NAS ] EXT4 Raid5 & 2 x m.2 SATA Samsung 850 Evo raid1 +16gb ddr4 Crucial+ QWA-AC2600 wireless+QXP PCIE
[Backup] QNAP TS-653A (Truenas Core) w. 4x 2TB Samsung F3 (HD203WI) RaidZ1 ZFS + 8gb ddr3 Crucial
[^] QNAP TL-D400S 2x 4TB WD Red Nas (WD40EFRX) 2x 4TB Seagate Ironwolf, Raid5
[^] QNAP TS-509 Pro w. 4x 1TB WD RE3 (WD1002FBYS) EXT4 Raid5
[^] QNAP TS-253D (Truenas Scale)
[Mobile NAS] TBS-453DX w. 2x Crucial MX500 500gb EXT4 raid1

Network
Qotom Pfsense|100mbps FTTH | Win11, Ryzen 5600X Desktop (1x2tb Crucial P50 Plus M.2 SSD, 1x 8tb seagate Ironwolf,1x 4tb HGST Ultrastar 7K4000)


Resources
[Review] Moogle's QNAP experience
[Review] Moogle's TS-877 review
https://www.patreon.com/mooglestiltzkin
User avatar
Moogle Stiltzkin
Guru
Posts: 11445
Joined: Thu Dec 04, 2008 12:21 am
Location: Around the world....
Contact:

Re: [GUIDE] backup and recover Portainer and docker apps

Post by Moogle Stiltzkin »

this other method for backing up dockers caught my eye

u install resilio using docker compose portainer. in this particular video they are using it to backup the docker apps. right now i am using hybridbackupsync to backup (manually). so now considering if resilio may be the way to go or not :'
https://www.youtube.com/watch?v=4hda0ib4DwQ


Backup Docker Containers using Resilio Sync *make sure to read the full instructions for setup here
https://thehomelab.wiki/books/docker/pa ... silio-sync

Install Resilio Sync
Install the LinuxServer Resilio Sync Docker container on your Docker host. I use this compose file.

Code: Select all

---
version: "2.1"
services:
  resilio-sync:
    image: linuxserver/resilio-sync
    container_name: resilio-sync
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
      - UMASK_SET=022
    volumes:
      - path to config:/config
      - path to downloads:/downloads
      - /:/sync
    ports:
      - 8888:8888
      - 55555:55555
    restart: unless-stopped





resilio qpkgs can be found here (i'd probly use the docker app though)
https://help.resilio.com/hc/en-us/artic ... 78964-QNAP


other qnappers using resilio or thinking to

https://www.reddit.com/r/qnap/comments/ ... _home_use/

https://www.reddit.com/r/qnap/comments/ ... lio_for_a/

https://www.reddit.com/r/qnap/comments/ ... g_anymore/


alternative to resilio is syncthing. not sure which is better though (only tested resilio so far)

Backing Up My Home Server Files - Setting Up Syncthing
https://www.youtube.com/watch?v=V4kWJ8JcdtM

https://www.myqnap.org/product/syncthing/



this other youtuber uses duplicati (if you don't want to use QNAPs HBS). He set it up as a docker app using portainer :mrgreen:
https://youtu.be/JoA6Bezgk1c?t=302


*update

after some testing it seems that the linuxserver/duplicati is not ideal for the qnap because i ran into issues. So i recommend using duplicati/duplicati :D

the duplicati/duplicati which runs as root user, solves the issues i had
drwtsn32
8 Jan

Hello and welcome!

Which Duplicati docker image are you using? The official duplicati one, or the linuxserver one? The linuxserver one doesn’t run Duplicati as root by default, so access issues are much more common.

In your docker config for this container, where are you mapping /backups ? Can you double check permissions on that folder from your normal NAS interface? If the error really does only happen at the end of the job, maybe it means it was able to write to /backups but not read from it. (Duplicati does a verification test at the end by reading three files and checking them.) Do you think you may have set the permissions to write-only on that folder?
https://forum.duplicati.com/t/access-ri ... -nas/13702
https://hub.docker.com/r/duplicati/duplicati/





if not mistaken, resilio and syncthing is good as detecting changes and syncing those changes to your backup in realtime. But because my backup is kept powered off when not backing up or restoring, this sync realtime is not as useful for me. Hence why i manually backup using HBS. But if you have a backup that is kept powered on/available all the time, you may want to consider something like resilio or syncthing to backup your docker apps :D
NAS
[Main Server] QNAP TS-877 (QTS) w. 4tb [ 3x HGST Deskstar NAS & 1x WD RED NAS ] EXT4 Raid5 & 2 x m.2 SATA Samsung 850 Evo raid1 +16gb ddr4 Crucial+ QWA-AC2600 wireless+QXP PCIE
[Backup] QNAP TS-653A (Truenas Core) w. 4x 2TB Samsung F3 (HD203WI) RaidZ1 ZFS + 8gb ddr3 Crucial
[^] QNAP TL-D400S 2x 4TB WD Red Nas (WD40EFRX) 2x 4TB Seagate Ironwolf, Raid5
[^] QNAP TS-509 Pro w. 4x 1TB WD RE3 (WD1002FBYS) EXT4 Raid5
[^] QNAP TS-253D (Truenas Scale)
[Mobile NAS] TBS-453DX w. 2x Crucial MX500 500gb EXT4 raid1

Network
Qotom Pfsense|100mbps FTTH | Win11, Ryzen 5600X Desktop (1x2tb Crucial P50 Plus M.2 SSD, 1x 8tb seagate Ironwolf,1x 4tb HGST Ultrastar 7K4000)


Resources
[Review] Moogle's QNAP experience
[Review] Moogle's TS-877 review
https://www.patreon.com/mooglestiltzkin
User avatar
Moogle Stiltzkin
Guru
Posts: 11445
Joined: Thu Dec 04, 2008 12:21 am
Location: Around the world....
Contact:

Re: [GUIDE] backup and recover Portainer and docker apps

Post by Moogle Stiltzkin »

i completed the duplicati docker app setup guide if you opt to use that for your backup/recovery
viewtopic.php?f=45&t=168810

*remember, a backup only counts as a backup if you store it on a SEPARATE storage device. so don't backup to same device and call it a day :lol:
NAS
[Main Server] QNAP TS-877 (QTS) w. 4tb [ 3x HGST Deskstar NAS & 1x WD RED NAS ] EXT4 Raid5 & 2 x m.2 SATA Samsung 850 Evo raid1 +16gb ddr4 Crucial+ QWA-AC2600 wireless+QXP PCIE
[Backup] QNAP TS-653A (Truenas Core) w. 4x 2TB Samsung F3 (HD203WI) RaidZ1 ZFS + 8gb ddr3 Crucial
[^] QNAP TL-D400S 2x 4TB WD Red Nas (WD40EFRX) 2x 4TB Seagate Ironwolf, Raid5
[^] QNAP TS-509 Pro w. 4x 1TB WD RE3 (WD1002FBYS) EXT4 Raid5
[^] QNAP TS-253D (Truenas Scale)
[Mobile NAS] TBS-453DX w. 2x Crucial MX500 500gb EXT4 raid1

Network
Qotom Pfsense|100mbps FTTH | Win11, Ryzen 5600X Desktop (1x2tb Crucial P50 Plus M.2 SSD, 1x 8tb seagate Ironwolf,1x 4tb HGST Ultrastar 7K4000)


Resources
[Review] Moogle's QNAP experience
[Review] Moogle's TS-877 review
https://www.patreon.com/mooglestiltzkin
User avatar
Moogle Stiltzkin
Guru
Posts: 11445
Joined: Thu Dec 04, 2008 12:21 am
Location: Around the world....
Contact:

Re: [GUIDE] backup and recover Portainer and docker apps

Post by Moogle Stiltzkin »

Just a thought. If you opt to use HBS to backup your docker apps, maybe use the setting for backup using snapshot as source (basically leave that box unstick so it will do so).

Reason being, if you are running a live docker app server, maybe those files will fluctuate constantly. So that can't be good while running a backup job. So using a snapshot solves this issue.

Or you can stop all running apps while u do the backup i suppose?
NAS
[Main Server] QNAP TS-877 (QTS) w. 4tb [ 3x HGST Deskstar NAS & 1x WD RED NAS ] EXT4 Raid5 & 2 x m.2 SATA Samsung 850 Evo raid1 +16gb ddr4 Crucial+ QWA-AC2600 wireless+QXP PCIE
[Backup] QNAP TS-653A (Truenas Core) w. 4x 2TB Samsung F3 (HD203WI) RaidZ1 ZFS + 8gb ddr3 Crucial
[^] QNAP TL-D400S 2x 4TB WD Red Nas (WD40EFRX) 2x 4TB Seagate Ironwolf, Raid5
[^] QNAP TS-509 Pro w. 4x 1TB WD RE3 (WD1002FBYS) EXT4 Raid5
[^] QNAP TS-253D (Truenas Scale)
[Mobile NAS] TBS-453DX w. 2x Crucial MX500 500gb EXT4 raid1

Network
Qotom Pfsense|100mbps FTTH | Win11, Ryzen 5600X Desktop (1x2tb Crucial P50 Plus M.2 SSD, 1x 8tb seagate Ironwolf,1x 4tb HGST Ultrastar 7K4000)


Resources
[Review] Moogle's QNAP experience
[Review] Moogle's TS-877 review
https://www.patreon.com/mooglestiltzkin
User avatar
Moogle Stiltzkin
Guru
Posts: 11445
Joined: Thu Dec 04, 2008 12:21 am
Location: Around the world....
Contact:

Re: [GUIDE] backup and recover Portainer and docker apps

Post by Moogle Stiltzkin »

so i tested out duplicati.

yes i could backup. but in the event of nas reinitialize, i would need to setup duplicati again before i am able to restore. but i'm hosting it from the same nas.... and to restore that i need to use setup duplicati..... but i cannot restore portainer using the original config until i had restored it first (using duplicati)....

so i went back to just using HBS since i know that works well. It's simple. Just backup the persistent storage location to your other storage device.

When you reinitialize your nas, you can just restore your container backups, then follow the steps i mentioned in my earlier post. Easy.
NAS
[Main Server] QNAP TS-877 (QTS) w. 4tb [ 3x HGST Deskstar NAS & 1x WD RED NAS ] EXT4 Raid5 & 2 x m.2 SATA Samsung 850 Evo raid1 +16gb ddr4 Crucial+ QWA-AC2600 wireless+QXP PCIE
[Backup] QNAP TS-653A (Truenas Core) w. 4x 2TB Samsung F3 (HD203WI) RaidZ1 ZFS + 8gb ddr3 Crucial
[^] QNAP TL-D400S 2x 4TB WD Red Nas (WD40EFRX) 2x 4TB Seagate Ironwolf, Raid5
[^] QNAP TS-509 Pro w. 4x 1TB WD RE3 (WD1002FBYS) EXT4 Raid5
[^] QNAP TS-253D (Truenas Scale)
[Mobile NAS] TBS-453DX w. 2x Crucial MX500 500gb EXT4 raid1

Network
Qotom Pfsense|100mbps FTTH | Win11, Ryzen 5600X Desktop (1x2tb Crucial P50 Plus M.2 SSD, 1x 8tb seagate Ironwolf,1x 4tb HGST Ultrastar 7K4000)


Resources
[Review] Moogle's QNAP experience
[Review] Moogle's TS-877 review
https://www.patreon.com/mooglestiltzkin
User avatar
Moogle Stiltzkin
Guru
Posts: 11445
Joined: Thu Dec 04, 2008 12:21 am
Location: Around the world....
Contact:

Re: [GUIDE] backup and recover Portainer and docker apps

Post by Moogle Stiltzkin »

Did a simple test

Q: does portainer and dockers persist after doing a soft reset? (1 beep, 3 second press on the reset button at the back of the nas)

A: yes. i tested this myself.

Basically you go qfinder, find your new nas ip. Go to the admin login page, add the mac address 1 for the password (use qfinder or check ur nas label for this)

change password. Then go virtual network (i set back the static ip). Then i created a virtual switch for the physical.

Next i went to container station and i started that up. After a short minute or so, it loaded up all the dockers.

Went to portainer, it works.

Checked a docker app from portainer it also works.

Checked virtual switch, everything seems account for.


So yes, you should be able to do a soft reset (e.g. if you got locked out of nas and need to get back in), and still able to have your docker apps persist. It took a few small quick changes to get back up and running again.
NAS
[Main Server] QNAP TS-877 (QTS) w. 4tb [ 3x HGST Deskstar NAS & 1x WD RED NAS ] EXT4 Raid5 & 2 x m.2 SATA Samsung 850 Evo raid1 +16gb ddr4 Crucial+ QWA-AC2600 wireless+QXP PCIE
[Backup] QNAP TS-653A (Truenas Core) w. 4x 2TB Samsung F3 (HD203WI) RaidZ1 ZFS + 8gb ddr3 Crucial
[^] QNAP TL-D400S 2x 4TB WD Red Nas (WD40EFRX) 2x 4TB Seagate Ironwolf, Raid5
[^] QNAP TS-509 Pro w. 4x 1TB WD RE3 (WD1002FBYS) EXT4 Raid5
[^] QNAP TS-253D (Truenas Scale)
[Mobile NAS] TBS-453DX w. 2x Crucial MX500 500gb EXT4 raid1

Network
Qotom Pfsense|100mbps FTTH | Win11, Ryzen 5600X Desktop (1x2tb Crucial P50 Plus M.2 SSD, 1x 8tb seagate Ironwolf,1x 4tb HGST Ultrastar 7K4000)


Resources
[Review] Moogle's QNAP experience
[Review] Moogle's TS-877 review
https://www.patreon.com/mooglestiltzkin
Post Reply

Return to “Users' Corner”