{"id":28275739,"url":"https://github.com/amirreza-jabbari/pgkeeper-cli","last_synced_at":"2025-10-26T13:33:08.529Z","repository":{"id":292570673,"uuid":"938451801","full_name":"Amirreza-Jabbari/PGKeeper-CLI","owner":"Amirreza-Jabbari","description":"PostgreSQL backup and restore CLI","archived":false,"fork":false,"pushed_at":"2025-05-10T19:30:56.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-21T04:16:15.172Z","etag":null,"topics":["postgresql-backup","python-cli"],"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/Amirreza-Jabbari.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-02-25T01:24:10.000Z","updated_at":"2025-05-10T19:30:59.000Z","dependencies_parsed_at":"2025-05-10T20:36:40.521Z","dependency_job_id":null,"html_url":"https://github.com/Amirreza-Jabbari/PGKeeper-CLI","commit_stats":null,"previous_names":["amirreza-jabbari/pgkeeper-cli"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amirreza-Jabbari%2FPGKeeper-CLI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amirreza-Jabbari%2FPGKeeper-CLI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amirreza-Jabbari%2FPGKeeper-CLI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amirreza-Jabbari%2FPGKeeper-CLI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Amirreza-Jabbari","download_url":"https://codeload.github.com/Amirreza-Jabbari/PGKeeper-CLI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amirreza-Jabbari%2FPGKeeper-CLI/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259048693,"owners_count":22797783,"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":["postgresql-backup","python-cli"],"created_at":"2025-05-21T04:15:47.798Z","updated_at":"2025-10-26T13:33:03.496Z","avatar_url":"https://github.com/Amirreza-Jabbari.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PGKeeper - PostgreSQL Backup and Restore CLI\n\nPGKeeper is a command-line tool for managing PostgreSQL database backups and restores. It leverages `pg_dump` and `pg_restore` (or `psql` for plain text dumps) to provide seamless backup and restoration functionality.\n\n## Features\n- **Backup PostgreSQL databases** using various dump formats (`custom`, `directory`, `tar`, `plain`)\n- **Restore backups** from both file-based and directory-based dumps\n- **Logging support** with configurable log levels and log file storage\n- **User-friendly CLI** with secure password handling\n\n## Installation\nEnsure you have the following dependencies installed:\n\n- Python 3.x\n- PostgreSQL utilities (`pg_dump`, `pg_restore`, `psql`)\n- `click` package for CLI support\n\n### Install dependencies\n```bash\npip install click\n```\n\n### Clone the repository\n```bash\ngit clone https://github.com/Amirreza-Jabbari/PGKeeper.git\ncd PGKeeper\n```\n\n## Usage\n\n### General Command Structure\n```bash\npython pgkeeper.py [OPTIONS] COMMAND [ARGS]...\n```\n\n### Available Commands\n- `backup` – Create a backup of a PostgreSQL database\n- `restore` – Restore a database from a backup\n\n### Logging Options\nYou can configure the log level and log file path:\n```bash\npython pgkeeper.py --log-level INFO --log-file pgkeeper.log\n```\n\n## Backup a PostgreSQL Database\n```bash\npython pgkeeper.py backup \\\n  --host localhost \\\n  --port 5432 \\\n  --username your_user \\\n  --dbname your_database \\\n  --backup-dir ./backups \\ (optional)\n  --format c \\ (optional)\n  --password your_password \\ (optional)\n  --log-level DEBUG \\ (optional)\n  --log-file pgkeeper.log \\ (optional/not recommended))\n```\n\n- `--host`: PostgreSQL server host.\n- `--port`: PostgreSQL server port.\n- `--username`: PostgreSQL username.\n- `--dbname`: PostgreSQL database name.\n- `--backup-dir`: Directory to store backups.\n- `--password`: PostgreSQL password. you can use `--password` or let PGKeeper ask for it for safer usage (recommended).\n- `--format`: Choose between `c` (custom), `d` (directory), `t` (tar), and `p` (plain SQL). default is `c`.\n- `log-level`: Choose between `DEBUG`, `INFO`, `WARNING`, `ERROR`, and `CRITICAL`. Default is `INFO`.\n- The backup is stored in the `./backups` directory with a timestamped filename.\n\n## Example\n```bash\npython pgkeeper.py backup --host localhost --port 5432 --username postgres --dbname db_name\n```\n\n## Restore a PostgreSQL Database\n```bash\npython pgkeeper.py restore \\\n  --host localhost \\\n  --port 5432 \\\n  --username your_user \\\n  --dbname your_database \\\n  --backup-file ./backups/backup_your_database_YYYYMMDD_HHMMSS.dump \\\n  --password your_password \\ (optional/not recommended)\n```\n\n- `--backup-file`: Path to the backup file.\n- If restoring from a `.sql` file, `psql` is used instead of `pg_restore`.\n\n## Example\n```bash\npython pgkeeper.py restore --host localhost --port 5432 --username postgres --dbname db_name --backup-file ./backups/backup_your_database_YYYYMMDD_HHMMSS.dump\n```\n\n## Error Handling and Logging\nLogs are stored in the specified log file (default: `backup_manager.log`). Log levels include:\n- `DEBUG` – Detailed debugging information\n- `INFO` – General operational messages\n- `WARNING` – Indications of potential issues\n- `ERROR` – Errors that occurred during operation\n- `CRITICAL` – Severe errors requiring immediate attention\n\n## Contributing\n1. Fork the repository\n2. Create a new branch (`git checkout -b feature-branch`)\n3. Commit your changes (`git commit -m 'feat: Add new feature'`)\n4. Push to the branch (`git push origin feature-branch`)\n5. Open a Pull Request\n\n## License\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famirreza-jabbari%2Fpgkeeper-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famirreza-jabbari%2Fpgkeeper-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famirreza-jabbari%2Fpgkeeper-cli/lists"}