Portainer
Setup
From my previous post, I am using a docker folder structure like `/home/<username>/Docker/<container>` to store my data and docker-compose files. So first make the Portainer folder
|
|
Next we take the basic template from before and setup our Portainer container.
|
|
So a few things I learned while setting up Portainer is that, in my last post, all my containers (traefik and whoami) were in the same docker-compose file. Therefore they used the same network interface. This isn’t true anymore as Portainer has its own file and we need to create a seperate network for all the containers to use together.
To make a new network run
|
|
I just call it `webproxy` because it is a proxy for my web-services.
We can now change the old traefik+whoami docker-compose file to look like this
|
|
As you can also see, I have commented out the port setting of the traefik container. This is done because I don’t want it to be accessible on `http://domain.com:8080`. I want it to be available exclusively on `https://traefik.domain.com`.
Going back to the Portainer file from above, I have made a few changed as seen here
|
|
Now we can start the container using `docker-compose up -d` and access it (after a minute or two) at `portainer.domain.com` First setup a username and password and then login.
Backup
I like to keep a simple daily backup of my Portainer data, so I can restore it if anything happens. Portainer doesn’t really store anything besides your login information, but I still like to have a backup. Like my folder `~/Docker`, I am creading a Backup folder in the same location.
|
|
Inside there, I want folders like my docker folder, so let us create a Portainer folder.
|
|
The script is a very simple bash script that backs up the data folder every day at 4am.
|
|
First we set up the environment and create two variables. `NOW` is a string like `20181017-0400` and `CURPATH` is just the current working path we want to use. Then we create a folder at the path with the date-name. Using `rsync` we copy the data from our Portainer folder to the backup folder.
In order to use the script we need to make it executabel
|
|
Since some of the files are protected, we need to use `sudo` to run the script. In order to run it automatically, set up a cron job
|
|
Add a line like
|
|
Here we want to execute the script every day at 4:00am
Restore
Restoring is just as simple.
|
|
If you moved your backup to another server or need to restore the date to another server, just use `scp` to move the data.
|
|