{"id":20364877,"url":"https://github.com/joeri-abbo/python-mysql-backupper","last_synced_at":"2026-04-11T15:39:13.942Z","repository":{"id":103510459,"uuid":"608826630","full_name":"Joeri-Abbo/python-mysql-backupper","owner":"Joeri-Abbo","description":"Backup a mysql to a gz file to have a backup on cron every hour.","archived":false,"fork":false,"pushed_at":"2024-12-06T23:54:34.000Z","size":226,"stargazers_count":0,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-18T11:41:25.449Z","etag":null,"topics":["automation","backup","backup-script","cron","db","mysql","slack"],"latest_commit_sha":null,"homepage":"","language":"Python","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/Joeri-Abbo.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":"2023-03-02T20:20:46.000Z","updated_at":"2024-09-13T21:01:32.000Z","dependencies_parsed_at":"2023-10-04T14:57:16.389Z","dependency_job_id":"97b8bf85-d3e5-4846-ba49-619f10a4dbd3","html_url":"https://github.com/Joeri-Abbo/python-mysql-backupper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joeri-Abbo%2Fpython-mysql-backupper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joeri-Abbo%2Fpython-mysql-backupper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joeri-Abbo%2Fpython-mysql-backupper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Joeri-Abbo%2Fpython-mysql-backupper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Joeri-Abbo","download_url":"https://codeload.github.com/Joeri-Abbo/python-mysql-backupper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241904711,"owners_count":20040021,"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":["automation","backup","backup-script","cron","db","mysql","slack"],"created_at":"2024-11-15T00:14:05.194Z","updated_at":"2025-12-31T01:03:21.001Z","avatar_url":"https://github.com/Joeri-Abbo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-mysql-backupper\n\nThis Python script creates a backup of a MySQL database and posts a message about the backup process to a Slack channel. It also sets up a Sentry instance to capture and report any exceptions that occur during the backup process.\n\n## Dependencies\n* Python 3.5 or higher\n* `json` module\n* `os` module\n* `subprocess` module\n* `datetime` module\n* `time` module\n* `requests` module\n* `yaml` module\n* `sentry_sdk` module\n\n## Configuration\n\nThe script requires a configuration file named `config.yml` which should be located in the same directory as the script. The `config.yml` file should have the following structure:\n```\nslack:\n  token: \u003cSLACK_API_TOKEN\u003e\n  channel: \u003cSLACK_CHANNEL_NAME\u003e\n\nmysql:\n  host: \u003cMYSQL_HOST\u003e\n  user: \u003cMYSQL_USER\u003e\n  passwd: \u003cMYSQL_PASSWORD\u003e\n  database: \u003cMYSQL_DATABASE_NAME\u003e\n\nsentry:\n  dsn: \u003cSENTRY_DSN\u003e\n\nname: \u003cDATABASE_NAME\u003e\n```\n\n* `SLACK_API_TOKEN`: The Slack API token for the bot.\n* `SLACK_CHANNEL_NAME`: The name of the Slack channel where the backup process messages should be posted.\n* `MYSQL_HOST`: The host name of the MySQL server.\n* `MYSQL_USER`: The username for the MySQL account.\n* `MYSQL_PASSWORD`: The password for the MySQL account.\n* `MYSQL_DATABASE_NAME`: The name of the MySQL database to be backed up.\n* `SENTRY_DSN`: The DSN (Data Source Name) for the Sentry instance. If no DSN is specified, Sentry will not be initialized.\n* `DATABASE_NAME`: The name of the database.\n\n## Usage\n\nTo use the script, simply run it using Python 3.5 or higher:\n```\npython main.py\n```\n\nThe script will create a backup file of the specified MySQL database and post a message to the specified Slack channel when the backup is complete. The message will include the size of the backup file. The script will also check if the backup file exists and report any errors.\n\nNote that the script uses the `mysqldump` command to create the backup file. Ensure that the `mysqldump` command is available in the system path before running the script.\n\n## Sentry\n\nThe script uses Sentry to capture and report any exceptions that occur during the backup process. If the `SENTRY_DSN` configuration variable is not specified, Sentry will not be initialized.\n\n## Slack\n\nThe `post_to_slack()` function in the script is responsible for posting messages to a Slack channel. It uses the Slack API to post the message. The `SLACK_API_TOKEN` configuration variable should be set to the API token for the bot. The `SLACK_CHANNEL_NAME` configuration variable should be set to the name of the channel where the message should be posted.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeri-abbo%2Fpython-mysql-backupper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoeri-abbo%2Fpython-mysql-backupper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeri-abbo%2Fpython-mysql-backupper/lists"}