{"id":15129789,"url":"https://github.com/lepikouze/backup-portainer-github","last_synced_at":"2026-02-28T02:44:49.672Z","repository":{"id":254622370,"uuid":"846943184","full_name":"lepikouze/backup-portainer-github","owner":"lepikouze","description":"This Docker container automates the backup of Docker stacks and environment files from Portainer to a GitHub repository. It is configurable and can be scheduled to run at specific intervals or according to a cron schedule.","archived":false,"fork":false,"pushed_at":"2025-03-24T15:49:38.000Z","size":52,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T16:38:25.275Z","etag":null,"topics":["backup","backup-script","docker","docker-compose","docker-container","docker-image","portainer","portainer-ce","portainer-stack"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lepikouze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-24T11:55:21.000Z","updated_at":"2025-03-24T15:49:43.000Z","dependencies_parsed_at":"2024-10-31T10:43:58.788Z","dependency_job_id":"ca4e8575-7c31-4d49-9ae2-1453c5c25fd1","html_url":"https://github.com/lepikouze/backup-portainer-github","commit_stats":null,"previous_names":["lepikouze/backup-portainer-github"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lepikouze%2Fbackup-portainer-github","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lepikouze%2Fbackup-portainer-github/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lepikouze%2Fbackup-portainer-github/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lepikouze%2Fbackup-portainer-github/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lepikouze","download_url":"https://codeload.github.com/lepikouze/backup-portainer-github/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247386305,"owners_count":20930622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","backup-script","docker","docker-compose","docker-container","docker-image","portainer","portainer-ce","portainer-stack"],"created_at":"2024-09-26T02:20:28.706Z","updated_at":"2026-02-28T02:44:44.639Z","avatar_url":"https://github.com/lepikouze.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# backup portainer github\n\n[![Docker Pulls](https://img.shields.io/docker/pulls/lepikouze/backup-portainer-github)](https://hub.docker.com/r/lepikouze/backup-portainer-github)\n[![GitHub last commit](https://img.shields.io/github/last-commit/lepikouze/backup-portainer-github)](https://github.com/lepikouze/backup-portainer-github/commits/main)\n[![GitHub License](https://img.shields.io/github/license/lepikouze/backup-portainer-github)](https://github.com/lepikouze/backup-portainer-github/blob/main/LICENSE)\n\nThis Docker container automates the backup of Docker stacks and environment files from Portainer to a GitHub repository. The solution is highly configurable, allowing you to schedule backups at specific intervals or via cron expressions.\n\n## Table of Contents\n\n- [Portainer Backup to GitHub](#portainer-backup-to-github)\n  - [Features](#features)\n  - [Quick Start](#quick-start)\n    - [Docker Compose](#docker-compose)\n    - [CLI](#cli)\n  - [Environment Variables](#environment-variables)\n  - [Volumes](#volumes)\n  - [Usage](#usage)\n  - [Support](#support)\n  - [Contributing](#contributing)\n  - [License](#license)\n  - [Acknowledgements](#acknowledgements)\n\n## Features\n\n- **Automated Backups**: Schedule regular backups of your Portainer stacks and environment files.\n- **Sensitive Information Masking**: Automatically hides sensitive information such as API keys and tokens.\n- **Flexible Scheduling**: Choose between cron-based scheduling or time intervals for backups.\n- **GitHub Integration**: Commits and pushes updates directly to a specified GitHub repository.\n\n## Quick Start\nYou can start using this container by deploying it with:\n\n### Docker Compose:\n\n```yaml\nversion: '3.9'\n\nservices:\n  backup-portainer-github:\n    container_name: ${TARGET_CONTAINER_NAME} \n    image: ghcr.io/lepikouze/backup-portainer-github:latest\n    environment:\n      PUID: 1000\n      PGID: 1000\n      PORTAINER_URL: ${PORTAINER_URL}\n      PORTAINER_USERNAME: ${PORTAINER_USERNAME}\n      PORTAINER_PASSWORD: ${PORTAINER_PASSWORD}\n      TARGET_CONTAINER_NAME: ${TARGET_CONTAINER_NAME}\n      STACKS_BASE_PATH: /stacks\n      GITHUB_USERNAME: ${GITHUB_USERNAME}\n      GITHUB_TOKEN: ${GITHUB_TOKEN}\n      GITHUB_REPO_NAME: ${GITHUB_REPO_NAME}\n      README_TITLE: ${README_TITLE} # Optional\n      README_DESCRIPTION: ${README_DESCRIPTION} # Optional\n      GITHUB_REPO_PATH: ${GITHUB_REPO_PATH} # Optional\n      #CRON_SCHEDULE: 0 0 4 * * 1 # Optional, use this OR INTERVAL_SECONDS, not both\n      INTERVAL_SECONDS: 60 # Optional, use this OR CRON_SCHEDULE, not both\n    ports:\n      - \"5000:5000\"\n    volumes:\n      - /folder/data:${GITHUB_REPO_PATH} # Optional\n      - /var/run/docker.sock:/var/run/docker.sock:ro\n      - /portainer_compose_directory:/stacks:ro\n\n    restart: unless-stopped\n```\n### CLI\n```bash\n# Set environment variables (replace with your actual values)\nexport PUID=1000\nexport PGID=1000\nexport PORTAINER_URL=https://your-portainer-url\nexport PORTAINER_USERNAME=your-portainer-username\nexport PORTAINER_PASSWORD=your-portainer-password\nexport TARGET_CONTAINER_NAME=portainer-backup\nexport STACKS_BASE_PATH=/stacks\nexport GITHUB_USERNAME=your-github-username\nexport GITHUB_TOKEN=your-github-token\nexport GITHUB_REPO_NAME=your-github-repo-name\nexport README_TITLE=\"Portainer Backup Automation\"  # Optional\nexport README_DESCRIPTION=\"Automated backup of Portainer stacks and environment files.\"  # Optional\nexport GITHUB_REPO_PATH=/folder/data/repo  # Optional\n# export CRON_SCHEDULE=\"0 0 4 * * 1\"  # Optional, uncomment if using cron schedule\nexport INTERVAL_SECONDS=60 # Optional, comment if using cron schedule\n\n# Run the Docker container\ndocker run -d \\\n  --name $TARGET_CONTAINER_NAME \\\n  --env PUID=$PUID \\\n  --env PGID=$PGID \\\n  --env PORTAINER_URL=$PORTAINER_URL \\\n  --env PORTAINER_USERNAME=$PORTAINER_USERNAME \\\n  --env PORTAINER_PASSWORD=$PORTAINER_PASSWORD \\\n  --env TARGET_CONTAINER_NAME=$TARGET_CONTAINER_NAME \\\n  --env STACKS_BASE_PATH=$STACKS_BASE_PATH \\\n  --env GITHUB_USERNAME=$GITHUB_USERNAME \\\n  --env GITHUB_TOKEN=$GITHUB_TOKEN \\\n  --env GITHUB_REPO_NAME=$GITHUB_REPO_NAME \\\n  --env README_TITLE=\"$README_TITLE\" \\  # Optional\n  --env README_DESCRIPTION=\"$README_DESCRIPTION\" \\  # Optional\n  --env GITHUB_REPO_PATH=$GITHUB_REPO_PATH \\  # Optional\n  --env INTERVAL_SECONDS=$INTERVAL_SECONDS \\  # Optional, use this OR CRON_SCHEDULE, not both\n  -p 5000:5000 \\\n  -v /folder/data:$GITHUB_REPO_PATH \\ # Optional\n  -v /var/run/docker.sock:/var/run/docker.sock:ro \\\n  -v /portainer_compose_directory:/stacks:ro \\\n  ghcr.io/lepikouze/backup-portainer-github:latest \\\n  --restart unless-stopped\n```\n\n\n## Environment Variables\n\n| Name                  | Description                                                                                       | Default                                |\n| --------------------- | ------------------------------------------------------------------------------------------------- | -------------------------------------- |\n| `PUID`                | User ID for file permissions within the container.                                                | `1000`                                 |\n| `PGID`                | Group ID for file permissions within the container.                                               | `1000`                                 |\n| `PORTAINER_URL`       | The URL of the Portainer instance to be backed up.                                                | **Required**                              |\n| `PORTAINER_USERNAME`  | Username for Portainer authentication.                                                            | **Required**                               |\n| `PORTAINER_PASSWORD`  | Password for Portainer authentication.                                                            | **Required**                              |\n| `TARGET_CONTAINER_NAME` | The name of this backup container within the Portainer environment.                             | **Required**                               |\n| `STACKS_BASE_PATH`    | Path inside the container where the Portainer stacks are stored.                                  | `/stacks`                              |\n| `GITHUB_USERNAME`     | GitHub username to authenticate and push backups.                                                 | **Required**                               |\n| `GITHUB_TOKEN`        | GitHub personal access token to authenticate and push backups.                                    | **Required**                               |\n| `GITHUB_REPO_NAME`    | Name of the GitHub repository where backups are stored.                                           | **Required**                               |\n| `README_TITLE`        | Title for the `README.md` file in the GitHub repository.                                          | `Portainer Backup Automation`          |\n| `README_DESCRIPTION`  | Description for the `README.md` file in the GitHub repository.                                    | `Automated backup of Portainer stacks and environment files.` |\n| `GITHUB_REPO_PATH`    | Local path inside the container where the GitHub repository is cloned.                            | `/tmp/repo`                            |\n| `CRON_SCHEDULE`       | (Optional) Cron expression for scheduling backups.                                                | `use this OR INTERVAL_SECONDS, not both`                                 |\n| `INTERVAL_SECONDS`    | (Optional) Interval in seconds between each backup execution.                                     | `use this OR CRON_SCHEDULE, not both`                                 |\n\n## Volumes\n\n| Path (Host)                                      | Path (Container)                      | Description                                                                |\n| ------------------------------------------------ | ------------------------------------- | -------------------------------------------------------------------------- |\n| `/folder/data`                   | `${GITHUB_REPO_PATH}`                 | Directory where backup data will be stored inside the container.           |\n| `/var/run/docker.sock`                           | `/var/run/docker.sock:ro`             | Docker socket to interact with the Docker API on the host (read-only).     |\n| `/portainer_compose_directory`                 | `/stacks:ro`                          | Directory containing Portainer stacks, mounted in read-only mode.          |\n\n## Usage\n\n### Build and Run the Container\n\nClone the repository and navigate to its directory:\n\n```bash\ngit clone https://github.com/lepikouze/backup-portainer-github.git\ncd backup-portainer-github\ndocker-compose up -d\n```\n\n### Access the Web Interface:\nOnce the container is running, you can access the web interface via: \n```bash\nhttp://localhost:5000\n```\n## Support\n\nFor support, please open an issue in the [GitHub repository](https://github.com/lepikouze/backup-portainer-github/issues). When reporting issues, please include logs and relevant configuration details to help with troubleshooting.\n\n\n## Contributing\n\nContributions are welcome! Please submit a Pull Request or open an Issue to discuss any changes or improvements.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgements\nProject Link: [lepikouze/backup-portainer-github](https://github.com/lepikouze/backup-portainer-github)\n\nThis project was inspired by [SavageSoftware/portainer-backup](https://github.com/SavageSoftware/portainer-backup).\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flepikouze%2Fbackup-portainer-github","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flepikouze%2Fbackup-portainer-github","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flepikouze%2Fbackup-portainer-github/lists"}