Giter Site home page Giter Site logo

savagesoftware / portainer-backup Goto Github PK

View Code? Open in Web Editor NEW
113.0 2.0 10.0 582 KB

Portainer Backup Utility

Dockerfile 3.36% JavaScript 88.99% Shell 7.65%
portainer docker backup backup-script portainer-ce portainer-api docker-image docker-container docker-compose

portainer-backup's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

portainer-backup's Issues

[Feature Request] Keep N backups

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"

{{DATE}} not updating the folder path using scheduled run

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

image

image

Thanks

Edit..everything works ok when using the backup command rather than schedule

image

Connection to Portainer Server Failed!

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

gminadak
savageautomate

" quotes in field values causing issues

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

Error with URL:
Portainer-Backup - URL error

Error with Cron
Portainer-Backup - Cron error

Backup error:
backup running with access code in speech marks

Successful backup:
successful backup with speech marks removed

Licensing clarification

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!

Test backup on running/scheduled docker container

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!

Cannot run via docker-compose: Error: Cannot find module '/portainer-backup/src/index.js

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: []
}

Can't connect to portainer

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:

Screenshot 2024-02-07 at 19 36 47

.. 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

Add linux/arm docker platform

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.

Unable to access portainer with http

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?

Cannot connect to portainer server using https

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 --------

Scheduling stacks

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.

Feature request: Backup into ZIP and keep_days

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.

Stacks with duplicate names

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.