{"id":28758556,"url":"https://github.com/drhdev/mhsnapshots","last_synced_at":"2025-06-17T04:08:53.799Z","repository":{"id":297970429,"uuid":"998450183","full_name":"drhdev/mhsnapshots","owner":"drhdev","description":"A simple snapshot tool for Hetzner Cloud Hosting with Telegram notification for Ubuntu 22.04.","archived":false,"fork":false,"pushed_at":"2025-06-08T16:51:57.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-08T17:30:51.184Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drhdev.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,"zenodo":null}},"created_at":"2025-06-08T16:26:47.000Z","updated_at":"2025-06-08T16:52:01.000Z","dependencies_parsed_at":"2025-06-08T17:41:15.450Z","dependency_job_id":null,"html_url":"https://github.com/drhdev/mhsnapshots","commit_stats":null,"previous_names":["drhdev/mhsnapshots"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/drhdev/mhsnapshots","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drhdev%2Fmhsnapshots","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drhdev%2Fmhsnapshots/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drhdev%2Fmhsnapshots/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drhdev%2Fmhsnapshots/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drhdev","download_url":"https://codeload.github.com/drhdev/mhsnapshots/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drhdev%2Fmhsnapshots/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260288446,"owners_count":22986668,"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":[],"created_at":"2025-06-17T04:08:53.113Z","updated_at":"2025-06-17T04:08:53.771Z","avatar_url":"https://github.com/drhdev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mhsnapshots - Hetzner Cloud Snapshot Manager\n\nA robust solution for managing snapshots of multiple Hetzner Cloud servers with Telegram notifications. This tool automatically creates, manages, and maintains snapshots for your Hetzner Cloud servers while keeping you informed through Telegram notifications.\n\n## Features\n\n- Automated snapshot creation and management for multiple Hetzner Cloud servers\n- Configurable retention policy per server\n- Real-time Telegram notifications for snapshot operations\n- Detailed logging with rotation\n- Support for multiple server configurations\n- Cross-platform compatibility (Linux, macOS)\n\n## Prerequisites\n\n- Python 3.8 or higher\n- Hetzner Cloud CLI (hcloud)\n- A Hetzner Cloud account with API access\n- A Telegram bot token and chat ID\n\n### Installing Hetzner Cloud CLI on Ubuntu 22.04\n\n1. Add the Hetzner Cloud repository:\n```bash\ncurl -fsSL https://packages.hetzner.com/hetzner-cloud-cli/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hetzner-cloud-cli-archive-keyring.gpg\necho \"deb [signed-by=/usr/share/keyrings/hetzner-cloud-cli-archive-keyring.gpg] https://packages.hetzner.com/hetzner-cloud-cli/ubuntu $(lsb_release -cs) main\" | sudo tee /etc/apt/sources.list.d/hetzner-cloud-cli.list\n```\n\n2. Update package list and install hcloud:\n```bash\nsudo apt update\nsudo apt install hcloud-cli\n```\n\n3. Verify installation:\n```bash\nhcloud version\n```\n\nNote: The official hcloud CLI is built and released for Linux/macOS/Windows x86_64 and FreeBSD—but not directly for Raspberry Pi’s ARM architecture, so you won’t find a ready-made ARM binary for Raspbian/Ubuntu on Pi but you can compile from source (Go). \n\n1.\tInstall Go (e.g. sudo apt install golang-go).\n\n2.\tClone the CLI repo:\n```bash\ngit clone https://github.com/hetznercloud/cli.git\ncd cli\n```\n\n3.\tBuild the binary:\n```bash\ngo build -o hcloud ./cmd/hcloud\n```\n\n4.\tMove the executable into your PATH:\n```bash\nsudo mv hcloud /usr/local/bin/\nhcloud version  # should run fine\n```\n\nThis approach works flawlessly on ARM and gives you the latest features.\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/yourusername/mhsnapshots.git\ncd mhsnapshots\n```\n\n2. Create and activate a Python virtual environment:\n```bash\npython3 -m venv venv\nsource venv/bin/activate\n```\n\n3. Install required Python packages:\n```bash\npip install -r requirements.txt\n```\n\n4. Create a `.env` file in the project root with your Telegram credentials:\n```bash\nTELEGRAM_BOT_TOKEN=your_bot_token_here\nTELEGRAM_CHAT_ID=your_chat_id_here\n```\n\n## Configuration\n\n### Server Configuration\n\n1. Copy the example configuration file:\n```bash\ncp configs/config.yaml.example configs/your-server-name.yaml\n```\n\n2. Edit the configuration file with your server details:\n```yaml\nserver:\n  id: \"123456\"                    # Your Hetzner Cloud server ID\n  name: \"example-server\"          # Server name (used for snapshot naming)\n  api_token: \"your-api-token\"     # Your Hetzner Cloud API token\n  retain_last_snapshots: 7        # Number of snapshots to retain\n```\n\nYou can create multiple configuration files for different servers in the `configs` directory.\n\n## Usage\n\n### Manual Execution\n\nRun the script manually:\n```bash\n./run_mhsnaps_telegram.sh\n```\n\n### Automated Execution with Cron\n\nTo run the script daily at 5 PM on Ubuntu 22.04:\n\n1. Make the script executable:\n```bash\nchmod +x run_mhsnaps_telegram.sh\n```\n\n2. Edit your crontab:\n```bash\ncrontab -e\n```\n\n3. Add the following line (adjust the path to match your installation):\n```bash\n0 17 * * * /path/to/mhsnapshots/run_mhsnaps_telegram.sh\n```\n\n## Project Structure\n\n```\nmhsnapshots/\n├── configs/                    # Server configuration files\n│   ├── config.yaml.example    # Example configuration\n│   └── your-server-name.yaml  # Your server configurations\n├── logs/                      # Log files directory\n├── src/                       # Source code\n│   ├── mhsnapshots.py        # Main snapshot management script\n│   └── log2telegram.py       # Telegram notification script\n├── venv/                      # Python virtual environment\n├── .env                       # Environment variables\n├── requirements.txt           # Python dependencies\n└── run_mhsnaps_telegram.sh    # Main execution script\n```\n\n## How It Works\n\n1. **Snapshot Creation**: The script creates a new snapshot for each configured server.\n2. **Retention Management**: Old snapshots are deleted based on the retention policy.\n3. **Logging**: All operations are logged to `logs/mhsnapshots.log`.\n4. **Telegram Notifications**: The script sends notifications for each operation via Telegram.\n\n### Log Format\n\nThe script generates detailed logs in the following format:\n```\nFINAL_STATUS | mhsnapshots.py | server-name | STATUS | hostname | timestamp | snapshot-name | total-snapshots\n```\n\n### Telegram Notifications\n\nNotifications are sent in a formatted Markdown message containing:\n- Script name\n- Server name\n- Operation status\n- Hostname\n- Timestamp\n- Snapshot name\n- Total snapshots\n\n## Troubleshooting\n\n### Common Issues\n\n1. **hcloud command not found**\n   - Ensure hcloud is properly installed\n   - Verify the installation path is in your system's PATH\n\n2. **Telegram notifications not working**\n   - Check your `.env` file for correct credentials\n   - Verify your Telegram bot token and chat ID\n   - Ensure the bot is added to the chat\n\n3. **Snapshot creation fails**\n   - Verify your Hetzner Cloud API token\n   - Check server ID and permissions\n   - Ensure sufficient disk space\n\n## License\n\nThis project is licensed under the GPL v3 License - see the LICENSE file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrhdev%2Fmhsnapshots","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrhdev%2Fmhsnapshots","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrhdev%2Fmhsnapshots/lists"}