{"id":41446946,"url":"https://github.com/octeth/octeth-mysql-backup-tool","last_synced_at":"2026-01-23T15:07:50.034Z","repository":{"id":325471392,"uuid":"867112455","full_name":"octeth/octeth-mysql-backup-tool","owner":"octeth","description":"This repository contains a set of Bash scripts designed to perform backups and restores of an Octeth MySQL 5.7 database using Percona XtraBackup.","archived":false,"fork":false,"pushed_at":"2025-11-21T13:59:23.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-21T15:32:09.881Z","etag":null,"topics":["backup","database","mysql","percona"],"latest_commit_sha":null,"homepage":"https://octeth.com/","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/octeth.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-03T13:24:58.000Z","updated_at":"2025-11-21T13:59:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/octeth/octeth-mysql-backup-tool","commit_stats":null,"previous_names":["octeth/octeth-mysql-backup-tool"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/octeth/octeth-mysql-backup-tool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octeth%2Focteth-mysql-backup-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octeth%2Focteth-mysql-backup-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octeth%2Focteth-mysql-backup-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octeth%2Focteth-mysql-backup-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/octeth","download_url":"https://codeload.github.com/octeth/octeth-mysql-backup-tool/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/octeth%2Focteth-mysql-backup-tool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28694465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T14:15:13.573Z","status":"ssl_error","status_checked_at":"2026-01-23T14:09:05.534Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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","database","mysql","percona"],"created_at":"2026-01-23T15:07:48.524Z","updated_at":"2026-01-23T15:07:50.027Z","avatar_url":"https://github.com/octeth.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚠️ DEPRECATED - This Repository is No Longer Maintained\n\n\u003e **WARNING:** This repository is deprecated and is no longer being maintained. No further updates, bug fixes, or support will be provided. Please consider using [Octeth's latest free backup tool](https://github.com/octeth/octeth-backup-tools)\n\n---\n\n# MySQL Backup and Restore Scripts using Percona XtraBackup and AWS S3\n\nThis repository contains a set of Bash scripts designed to perform backups and restores of a MySQL 5.7 database using Percona XtraBackup. The backups are compressed and stored locally, with the option to upload them to AWS S3 for long-term and short-term storage. The scripts are compatible with Ubuntu 22.04 or newer versions and leverage Docker to run Percona XtraBackup 2.4 and AWS CLI.\n\nThis tool is built specifically for [Octeth Email Marketing Software](https://octeth.com/).\n\n---\n\n## Table of Contents\n\n- [Prerequisites](#prerequisites)\n- [Setup and Installation](#setup-and-installation)\n  - [Clone the Repository](#clone-the-repository)\n  - [Configure Environment Variables](#configure-environment-variables)\n  - [Run the Installation Script](#run-the-installation-script)\n- [Usage](#usage)\n  - [Performing a Backup](#performing-a-backup)\n  - [Restoring from a Backup](#restoring-from-a-backup)\n- [Scripts Overview](#scripts-overview)\n  - [install.sh](#installsh)\n  - [backup.sh](#backupsh)\n  - [restore.sh](#restoresh)\n- [Configuration](#configuration)\n  - [.env File](#env-file)\n- [Automation](#automation)\n- [Security Considerations](#security-considerations)\n- [Troubleshooting](#troubleshooting)\n- [Contributions and Feedback](#contributions-and-feedback)\n- [Acknowledgments](#acknowledgments)\n- [Disclaimer](#disclaimer)\n\n---\n\n## Prerequisites\n\nBefore using these scripts, ensure that you have the following installed and configured on your Ubuntu 22.04 system:\n\n- **Docker**: To run Percona XtraBackup and AWS CLI in containers.\n- **MySQL 5.7**: The database you intend to back up.\n\n**Note**: The scripts perform all operations within Docker containers, eliminating the need to install additional software on the host system besides Docker.\n\n---\n\n## Setup and Installation\n\n### Clone the Repository\n\n```bash\ngit clone git@github.com:octeth/octeth-mysql-backup-tool.git\ncd innodb-backup-tool\n```\n\n### Configure Environment Variables\n\nCreate a `.env` file in the root directory of the repository to store configuration variables.\n\n```bash\ncp .env.example .env\n```\n\nEdit the `.env` file and add your configuration variables. See the [Configuration](#configuration) section for details.\n\n### Run the Installation Script\n\nThe `install.sh` script installs Docker (if not already installed) and pulls the required Docker images.\n\n```bash\nsudo chmod +x install.sh\nsudo ./install.sh\n```\n\n---\n\n## Usage\n\n### Performing a Backup\n\nRun the `backup.sh` script to perform a backup of your MySQL database.\n\n```bash\nsudo chmod +x backup.sh\nsudo ./backup.sh\n```\n\nThe script will:\n\n- Create a compressed backup of your MySQL data directory using Percona XtraBackup within a Docker container.\n- **Optionally** upload the backup to AWS S3 using the AWS CLI Docker image if AWS credentials are provided.\n- If AWS credentials are not set, the backup will be stored locally.\n- Inform you of the backup file's location if not uploaded to S3.\n\n### Restoring from a Backup\n\nTo restore your database from a backup, run the `restore.sh` script.\n\n1. Ensure you have the exact backup file name you wish to restore (e.g., `innodb_backup_2023-10-01_02-00-00.xbstream.gz`).\n\n2. Run the script, passing the backup file name as an argument:\n\n   ```bash\n   sudo chmod +x restore.sh\n   sudo ./restore.sh innodb_backup_2023-10-01_02-00-00.xbstream.gz\n   ```\n\nThe script will:\n\n- **Optionally** download the specified backup from AWS S3 if AWS credentials are provided.\n- If AWS credentials are not set, it will look for the backup file in the local backup directory.\n- Decompress and extract the backup files using Percona XtraBackup within a Docker container.\n- Stop the MySQL service or container.\n- Clean the existing MySQL data directory.\n- Restore the backup to the data directory.\n- Adjust file ownership.\n- Start the MySQL service or container.\n- Clean up the local backup files.\n\n---\n\n## Scripts Overview\n\n### install.sh\n\nThis script prepares the environment by:\n\n- **Installing Docker**: Checks if Docker is installed and installs it if necessary.\n- **Pulling Docker Images**:\n  - `percona/percona-xtrabackup:2.4` for performing backups and restores.\n  - `amazon/aws-cli` for AWS S3 interactions.\n\n### backup.sh\n\nThis script performs the backup process:\n\n- **Loads Configuration**: Reads variables from the `.env` file.\n- **Generates Filenames**: Uses date-based variables for naming the backup files.\n- **Creates Backup Directory**: Ensures the local backup directory exists.\n- **Performs Backup**: Runs Percona XtraBackup inside a Docker container to create a compressed backup.\n- **Uploads to S3 (Optional)**: If AWS credentials are provided, uses the AWS CLI Docker image to upload the backup to AWS S3.\n- **Local Backup Retention**: If AWS credentials are not set, the backup remains in the local directory.\n- **Cleans Up**: Removes the local backup file after successful upload to S3.\n\n### restore.sh\n\nThis script restores the database from a backup:\n\n- **Loads Configuration**: Reads variables from the `.env` file.\n- **Downloads Backup (Optional)**: If AWS credentials are provided, uses the AWS CLI Docker image to download the specified backup from S3.\n- **Local Backup Usage**: If AWS credentials are not set, the script uses the backup file from the local backup directory.\n- **Prepares Backup**: Decompresses and extracts the backup using Percona XtraBackup inside a Docker container.\n- **Stops MySQL**: Stops the MySQL service or Docker container.\n- **Cleans Data Directory**: Removes existing data in the MySQL data directory.\n- **Restores Backup**: Copies the backup data into the MySQL data directory using Percona XtraBackup.\n- **Adjusts Ownership**: Sets correct permissions on the data directory.\n- **Starts MySQL**: Restarts the MySQL service or Docker container.\n- **Cleans Up**: Removes temporary files from the backup directory.\n\n---\n\n## Configuration\n\n### .env File\n\nAll configuration variables are stored in the `.env` file located in the root directory of the repository. Below is an example of what the `.env` file should contain:\n\n```bash\n# .env file\n\n# AWS S3 Configuration\nS3_BUCKET=\"s3://your-s3-bucket-name\"\n\n# Backup Directories\nDATA_DIR=\"/var/lib/mysql\"        # Path to your MySQL data directory\nBACKUP_DIR=\"/root/mysql_backups\" # Local directory to store backups\nMYSQL_DATA_DIR=\"/var/lib/mysql\"  # MySQL data directory for restore\n\n# AWS Credentials (leave empty if not using AWS S3)\nAWS_ACCESS_KEY_ID=\"\"\nAWS_SECRET_ACCESS_KEY=\"\"\nAWS_DEFAULT_REGION=\"\"\n\n# Backup Storage Configuration\nLONGTERM=\"longterm\"    # S3 folder for long-term backups\nSHORTTERM=\"shortterm\"  # S3 folder for short-term backups\n\n# MySQL Docker Container Name (if using MySQL in Docker)\nMYSQL_CONTAINER_NAME=\"\"  # Set this if MySQL is running in a Docker container\n```\n\n**Notes:**\n\n- **AWS Credentials**:\n  - If `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_DEFAULT_REGION` are set to empty values, the scripts will skip uploading backups to S3.\n  - When restoring, if AWS credentials are not provided, the script will look for the backup file in the local backup directory.\n- **Local Backups**:\n  - Ensure that your `BACKUP_DIR` has sufficient storage space and is secured appropriately.\n- **MySQL Data Directory**:\n  - Update the `DATA_DIR` and `MYSQL_DATA_DIR` variables if your MySQL data directory is located elsewhere.\n- **MySQL Container**:\n  - If your MySQL server is running inside a Docker container, set `MYSQL_CONTAINER_NAME` to the container's name.\n\n---\n\n## Automation\n\nTo automate the backup process, you can schedule the `backup.sh` script using `cron`.\n\n### Scheduling Backups with Cron\n\n1. Open the crontab editor:\n\n   ```bash\n   sudo crontab -e\n   ```\n\n2. Add a cron job to run the backup script at your desired schedule. For example, to run the backup daily at 2 AM:\n\n   ```cron\n   0 2 * * * /path/to/innodb-backup-tool/backup.sh \u003e\u003e /var/log/mysql_backup.log 2\u003e\u00261\n   ```\n\n3. Save and exit the crontab editor.\n\n**Note**:\n\n- Ensure that the script paths are correct.\n- The user running the cron job must have sufficient permissions to execute the script and access Docker.\n- Redirecting output to a log file (`\u003e\u003e /var/log/mysql_backup.log 2\u003e\u00261`) helps in monitoring the backup process.\n\n---\n\n## Security Considerations\n\n- **Sensitive Data**: Avoid committing the `.env` file to version control if it contains sensitive information.\n  - Add `.env` to your `.gitignore` file.\n- **File Permissions**: Set appropriate permissions on the `.env` file and backup directories to prevent unauthorized access.\n\n  ```bash\n  chmod 600 .env\n  chmod -R 700 /root/mysql_backups\n  ```\n\n- **AWS Credentials**:\n  - If possible, use AWS IAM roles, AWS CLI configuration files, or environment variables instead of hardcoding credentials in the `.env` file.\n  - When AWS credentials are not set, backups will not be uploaded to S3; ensure that local backups are secured and managed appropriately.\n- **Data Encryption**:\n  - For an additional layer of security, consider encrypting your backups before uploading them to S3. AWS S3 supports server-side encryption.\n  - Encrypt local backups if they contain sensitive data and are stored on the server.\n- **Docker Security**:\n  - Ensure that Docker is securely configured and that only authorized users can execute Docker commands.\n- **Logging**:\n  - Redirect script output to log files and secure them appropriately.\n- **Access Control**:\n  - Limit access to the server and ensure only trusted personnel can run the scripts.\n- **Backup Retention Policy**:\n  - Implement a policy for how long local backups are retained if not uploading to S3.\n  - Regularly monitor and clean up old backups to manage disk space.\n\n---\n\n## Troubleshooting\n\n- **Backup Fails Immediately**:\n  - Check the Docker logs for the `percona/percona-xtrabackup` container.\n  - Ensure the `DATA_DIR` path is correct and accessible.\n- **AWS S3 Upload Fails**:\n  - Verify that AWS credentials are correctly set in the `.env` file.\n  - Ensure the S3 bucket name and path are correct.\n  - If AWS credentials are not set, the script will skip the upload.\n- **Restore Process Issues**:\n  - Confirm that the backup file name provided to `restore.sh` matches the backup you intend to restore.\n  - Ensure that the MySQL service or container is properly stopped before restoring.\n  - If AWS credentials are not set, ensure the backup file exists in the local backup directory.\n- **Permission Errors**:\n  - Ensure you run the scripts with sufficient privileges (`sudo` may be required).\n  - Verify that the `chown` command in `restore.sh` points to the correct user and group (`mysql:mysql`).\n- **Docker Errors**:\n  - Ensure Docker is running and that you have permission to execute Docker commands.\n  - Check for conflicts with container names if multiple backups are run simultaneously.\n\n---\n\n## Contributions and Feedback\n\nContributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/cemhurturk/innodb-backup-tool/issues) or submit a pull request.\n\n---\n\n## Acknowledgments\n\n- **Percona XtraBackup**: An open-source hot backup utility for MySQL-based servers.\n- **AWS S3**: Scalable storage in the cloud provided by Amazon Web Services.\n- **Docker**: A platform for developing, shipping, and running applications in containers.\n- **Octeth Email Marketing Software**: The software for which this backup tool was specifically built.\n\n---\n\n## Disclaimer\n\nThese scripts are provided as-is without any warranty. Use them at your own risk, and always ensure you have proper backups before performing restore operations.\n\n---\n\n*For any questions or support, please contact [cem.hurturk@gmail.com](mailto:cem.hurturk@gmail.com).*\n\n---\n\n# Thank You\n\nWe hope this tool assists you in effectively managing your MySQL backups and restores. Your feedback is invaluable; please don't hesitate to reach out with any suggestions or improvements.\n\n---\n\n# Shortcuts\n\n- **[Back to Top](#mysql-backup-and-restore-scripts-using-percona-xtrabackup-and-aws-s3)**\n\n---\n\n*Happy backing up!*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focteth%2Focteth-mysql-backup-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Focteth%2Focteth-mysql-backup-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focteth%2Focteth-mysql-backup-tool/lists"}