{"id":41223465,"url":"https://github.com/solectrus/backup-restore","last_synced_at":"2026-01-23T00:26:02.686Z","repository":{"id":259443139,"uuid":"868365280","full_name":"solectrus/backup-restore","owner":"solectrus","description":"Create (and restore) backups of the SOLECTRUS databases","archived":false,"fork":false,"pushed_at":"2025-02-28T09:07:14.000Z","size":18,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-05T04:57:53.164Z","etag":null,"topics":["backup","influxdb","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/solectrus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-10-06T07:33:23.000Z","updated_at":"2025-02-28T09:07:17.000Z","dependencies_parsed_at":"2024-10-25T13:14:12.478Z","dependency_job_id":"d47102c9-b7ba-4432-ad55-0aebf1ee4e5d","html_url":"https://github.com/solectrus/backup-restore","commit_stats":null,"previous_names":["solectrus/backup-restore"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/solectrus/backup-restore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solectrus%2Fbackup-restore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solectrus%2Fbackup-restore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solectrus%2Fbackup-restore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solectrus%2Fbackup-restore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solectrus","download_url":"https://codeload.github.com/solectrus/backup-restore/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solectrus%2Fbackup-restore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28676010,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T20:48:19.482Z","status":"ssl_error","status_checked_at":"2026-01-22T20:48:14.968Z","response_time":144,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","influxdb","postgresql"],"created_at":"2026-01-23T00:26:02.109Z","updated_at":"2026-01-23T00:26:02.676Z","avatar_url":"https://github.com/solectrus.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SOLECTRUS Backup \u0026 Restore\n\nThis repository contains scripts to backup and restore both PostgreSQL and InfluxDB databases for a SOLECTRUS installation. The following scripts are provided:\n\n## backup.sh\n\nThe `backup.sh` script creates backups of both PostgreSQL and InfluxDB databases and combines them into a single compressed file. It is designed specifically for use within a SOLECTRUS setup, ensuring consistent backups of the required services.\n\nHow it works:\n\n- A PostgreSQL backup is created using `pg_dumpall` and compressed with `gzip`.\n- An InfluxDB backup is created using the `influx backup` command.\n- Both backups are combined into a single `tar.gz` file named `solectrus-backup-\u003cDATE\u003e.tar.gz`.\n\nUsage:\n\n```bash\n./backup.sh\n```\n\nThe backup file will be saved in the current directory with the format `solectrus-backup-\u003cDATE\u003e.tar.gz`, where `\u003cDATE\u003e` is the current date.\n\nYou can optionally provide a target directory where the backup file should be stored:\n\n```bash\n./backup.sh --backup-dir /path/to/backups\n```\n\nYou can also specify the number of days to keep backups (older backups will be deleted):\n\n```bash\n./backup.sh --retention-days 10\n```\n\nWithout specifying `--retention-days`, older backups will not be deleted.\n\n## restore.sh\n\nThe `restore.sh` script restores both PostgreSQL and InfluxDB databases from a previously created backup file. It ensures that only PostgreSQL and InfluxDB containers are running during the restore process to prevent any conflicts.\n\nHow it works:\n\n- It checks for the presence of a valid `.env` file and a valid Docker Compose configuration using `docker compose config`.\n- It extracts the combined backup file and restores the databases.\n- The PostgreSQL database is restored using `psql`, and the InfluxDB database is restored using the `influx restore` command.\n- It stops all other containers except PostgreSQL and InfluxDB during the restore process.\n\nUsage:\n\n```bash\n./restore.sh \u003cBACKUP_FILE\u003e\n```\n\nYou need to provide the filename of the backup (containing the date as YYYY-MM-DD) as a parameter, e.g.:\n\n```bash\n./restore.sh /path/to/backups/solectrus-backup-2024-10-06.tar.gz\n```\n\nRequirements:\n\n- Valid SOLECTRUS installation (including both PostgreSQL and InfluxDB services)\n- Docker Compose configuration file (e.g., `docker-compose.yml` or `compose.yaml`)\n- `.env` file with necessary environment variables for InfluxDB\n\nWith these scripts, you can easily manage the backup and restore processes for PostgreSQL and InfluxDB databases in your SOLECTRUS setup.\n\n## Download and Installation\n\nTo use the scripts, you can download them directly into your SOLECTRUS installation directory:\n\n```bash\n# Change to your SOLECTRUS installation directory\ncd /path/to/solectrus\n\n# Download backup.sh and restore.sh\ncurl -o backup.sh https://raw.githubusercontent.com/solectrus/backup-restore/refs/heads/main/backup.sh\ncurl -o restore.sh https://raw.githubusercontent.com/solectrus/backup-restore/refs/heads/main/restore.sh\n\n# Make both scripts executable\nchmod +x backup.sh restore.sh\n```\n\n## Automating Backups with CRON\n\nTo ensure regular backups, you can set up a cron job to execute the backup script automatically, e.g. daily at a specific time. Here's how you can do it:\n\n1. Open the crontab editor:\n\n   ```bash\n   crontab -e\n   ```\n\n2. Add the following line to schedule a daily backup at 2:00 AM:\n\n   ```bash\n   0 2 * * * cd /path/to/solectrus \u0026\u0026 ./backup.sh --backup-dir /path/to/backups --retention-days 10\n   ```\n\n   **Explanation:**\n\n   - `0 2 * * *` → Runs the backup script daily at 2:00 AM\n   - `cd /path/to/solectrus` → Path to the backup script (change to your SOLECTRUS installation directory)\n   - `--backup-dir /path/to/backups` → Directory where backups will be stored (change to your desired backup directory)\n   - `--retention-days 10` → Optional parameter to specify the number of days to keep backups (deleting older backups)\n\nTo verify that the cron job is active, run:\n\n```bash\ncrontab -l\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolectrus%2Fbackup-restore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolectrus%2Fbackup-restore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolectrus%2Fbackup-restore/lists"}