savagesoftware / portainer-backup Goto Github PK
View Code? Open in Web Editor NEWPortainer Backup Utility
Portainer Backup Utility
Thank you for your work and your time.
It would be nice to have an option to keep only specified number of backups.
To use with:
--filename "portainer-backup-{{DATE}}.tar.gz"
Hi,
unless I missed it, it doesn't seems possible to use a Docker secret to store the Portainer token, could you add an option/environment variable to read the token from a file?
Thank you for this utility, best, Alexandre
Hi
First of all, awesome tool
I'm having an issue with the folder path not updating when running on a schedule. Below is a screenshot of my docker compose with {{DATE}} in the path and also the log showing the incorrect folder being used for the backup
Thanks
Edit..everything works ok when using the backup command rather than schedule
Hello,
When trying to install the Portainer backup via Docker I am getting the following error messages. Im not quite clear on what I might be needing to correct or double check here. Any advice would help. Thank you!
Here is the errors and a screenshot of what im seeing.
✖ Connection to portainer server failed!
│ ✖ -------------------------- ERROR -------------------------- ✖ │ ├──┤ │ ERROR MESSAGE │ getaddrinfo ENOTFOUND portainer
Initializing operation : ✔ TEST Validating target backup directory : ✔ EXISTS → /backup Validating target backup file : ✔ DRYRUN → portainer-backup.tar.gz Validating portainer server : ✖ http://portainer:9000
Out of the blue Portainer-Backup stopped being able to connect to the Portainer server and subsequently read the Cron settings correctly when they are encased in " quotes.
I haven't made any changes to the install, but as part of troubleshooting I checked the docker network settings for the container (it shares the same docker network as Portainer and Portainer Agent). Also tried changing Portainer to localhost/127.0.0.1 etc. Then the host IP instead. Still no joy.
As a last gasp I removed the quotes " from the URL. Tried it again and this time it complained about the Cron format instead. Partial success. I removed the " from the Cron schedule entry. Tried again, everything looked like it was ok but the backup failed. So remove the " quotes from the backup token and finally got a successful backup.
I don't know if this issue is local to just me, I just wanted to flag what I have experienced in case it hits wider.
Working configuration (backup token blanked). It is almost a carbon copy of your example but now with the quotes " removed.
version: '3.8'
services:
portainer-backup:
container_name: portainer-backup
image: savagesoftware/portainer-backup:latest
hostname: portainer-backup
restart: unless-stopped
command: schedule
environment:
- TZ=Europe/London
- PUID=1000
- PGID=1000
- stdin_open=true # docker run -i
- tty=true # docker run -t 0
- PORTAINER_BACKUP_URL=http://portainer:9000
- PORTAINER_BACKUP_TOKEN=ptr_=
- PORTAINER_BACKUP_PASSWORD=
- PORTAINER_BACKUP_OVERWRITE=1
- PORTAINER_BACKUP_SCHEDULE=0 0 0 * * *
- PORTAINER_BACKUP_STACKS=1
- PORTAINER_BACKUP_DRYRUN=0
- PORTAINER_BACKUP_CONCISE=1
- PORTAINER_BACKUP_DIRECTORY=/backup
- PORTAINER_BACKUP_FILENAME=portainer-backup.tar.gz
volumes:
- portainer-backup:/backup
networks:
- portainer
networks:
portainer:
external: true
volumes:
portainer-backup:
external: true
Hello!
The portainer-backup does not contain a LICENCE file at repository, in the source file have a copyright notice but no explicit permissions about the code.
Can you @savageautomate clarify the terms of you code usage?
Thanks!
Was having trouble testing my scheduled docker container. After some playing around, it seems the correct command is:
docker exec portainer-backup npm run backup
In case you want to update in the readme.
Thanks for the great work by the way!
When using the docker-compose workflow at the bottom of the portainer-backup readme, no backup is generated by cron job. The following error can be seen in the container logs:
Error: Cannot find module '/portainer-backup/src/index.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
hi all, i'd really like to try and get this working but I'm running into a bit of a wall. Whatever I try, I'm unable to connect to portainer.
Firstly, my portainer container has these ports:
.. so I presumed the PORTAINER_BACKUP_URL
should be "http://192.168.1.14:8000
" (192.168.1.14
being the server it's on), however the logs show Validating portainer server failing with Request failed with status code 404
I tried PORTAINER_BACKUP_URL: "http://portainer:8000"
but this produces an error of getaddrinfo EAI_AGAIN portainer
PORTAINER_BACKUP_URL: "http://portainer:9000"
also produces getaddrinfo EAI_AGAIN portainer
PORTAINER_BACKUP_URL: "http://192.168.1.14:9000"
produces an error saying ECONNREFUSED 192.168.1.14:9000
My portainer container network is 'bridge
', so I tried putting portainer-backup also on the bridge
network, but it made no difference to the error messages
At this point I'm stumped, so I must be missing something obvious. Any ideas?
This is my compose, to help maybe spot what I've done wrong
version: '3.8'
services:
portainer-backup:
container_name: portainer-backup
image: savagesoftware/portainer-backup:latest
hostname: portainer-backup
restart: unless-stopped
command: schedule
environment:
TZ: Europe/London
PORTAINER_BACKUP_URL: "http://192.168.1.14:9000"
PORTAINER_BACKUP_TOKEN: "_redacted_"
PORTAINER_BACKUP_PASSWORD: ""
PORTAINER_BACKUP_OVERWRITE: 1
PORTAINER_BACKUP_SCHEDULE: "33 19 * * *"
PORTAINER_BACKUP_STACKS: 1
PORTAINER_BACKUP_DRYRUN: 0
PORTAINER_BACKUP_CONCISE: 1
PORTAINER_BACKUP_DIRECTORY: "/home/crispy/docker/portainer-backups/automatic"
PORTAINER_BACKUP_FILENAME: "nas-portainer-backup-{{yyyy-MM-dd}}.tar.gz"
volumes:
- /home/crispy/docker/portainer-backups/automatic:/backup
First of all, thank you for this great project!
Would you mind adding the linux/arm platform to your docker images? This would add the possibility to run the images e.g. on a raspberry pi.
I've ports 8000:8000 and 9443:9443 for portainer.
I can access port 9443 to manage portainer fine, with port 8000 I get 'not found'.
This is the default install of portainer (as far as I can tell).
What did I miss/do wrong?
HI,
I was hoping to use your create little utility to run nightly backups of my portainer server, but it gives me the following error.
Do you only support http connections?
___ _ _ ___ _
| _ \___ _ _| |_ __ _(_)_ _ ___ _ _ | _ ) __ _ __| |___ _ _ __
| _/ _ \ '_| _/ _` | | ' \/ -_) '_| | _ \/ _` / _| / / || | '_ \
|_| \___/_| \__\__,_|_|_||_\___|_| |___/\__,_\__|_\_\\_,_| .__/
|_|
┌──────────────────────────────────────────────────────────────────┐
│ Made with ♥ by SavageSoftware, LLC © 2022 (Version 0.0.7) │
└──────────────────────────────────────────────────────────────────┘
Initializing operation : ✔ SCHEDULE
Validating portainer server : ✖ https://portainer.lan:9443
┌────────────────────────────────────────────┐
│ ✖ Connection to portainer server failed! │
└────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────┐
│ ✖ -------------------------- ERROR -------------------------- ✖ │
├───────────────┬──────────────────────────────────────────────────┤
│ ERROR MESSAGE │ unable to verify the first certificate │
└───────────────┴──────────────────────────────────────────────────┘
-------- GOODBYE --------
Thanks so much for this software - I've been looking for something like this for a very long time.
Is it possible to do a stacks only backup with the schedule command? I can't get the container to run if I try and use both commands. I don't want to backup all the data - just the stacks on a schedule.
Thanks for any help.
Hello,
What a great tool !!! Love this so much.
Would be great when the output of the back can be zipped. With a custom given filename for example:
Backup-{date}-{time}
And a custom given value how many days you want keep backups. So if you give 5, then the last 5 backups will remain.
Add a new one. Then de oldest will deleted. So you will have multiple backups to fallback on.
I use Portainer with multiple environments, and some stack names are the same between them.
This causes the script to not backup all stacks, because it overwrites the yml files (because they only contain the stack name and not the environment name).
This could be easily solved by including the stack ID or environment name in the resulting filename (or only when the file already exist).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.