Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
betschki committed Aug 4, 2024
1 parent 40ec504 commit 4401095
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

This repository is an open-source tool designed to create and manage MySQL database backups. It allows you to store backups both onsite (e.g., on your own server or NAS) and offsite (e.g., on an S3-compatible storage). This ensures data redundancy and security, protecting against data loss in various scenarios.
This repository is an open-source tool designed to create and manage MySQL database backups. It allows you to store backups both onsite (e.g., on your own server or NAS) and offsite (e.g., on S3-compatible storage). This ensures data redundancy and security, protecting against data loss in various scenarios.

This tool was developed for the specific use case at [Magic Pages](https://magicpages.com), a managed Ghost CMS hosting provider, to maintain robust backups of all databases. However, it can be used by anyone needing a reliable MySQL backup solution.

Expand All @@ -23,14 +23,14 @@ This tool was developed for the specific use case at [Magic Pages](https://magic

## Installation

1. **Clone the Repository:**
1. **Clone the Repository**

```sh
git clone https://github.com/magicpages/mysql-onsite-offsite-backup.git
cd mysql-onsite-offsite-backup
```

2. Create and Configure the .env File:
2. **Create and Configure the .env File**

Create a .env file in the root directory and fill in the necessary environment variables:

Expand All @@ -52,16 +52,16 @@ MONTHLY_RETENTION=6
YEARLY_RETENTION=2
```

3. Build and Run the Docker Container:
3. **Build and Run the Docker Container**

```sh
docker-compose build
docker-compose up -d
docker compose up -d
```

## Usage

### Backup

The backup process is automated using a cron job configured in the Docker container. The backup script will:

1. Connect to the MySQL server.
Expand All @@ -71,16 +71,18 @@ The backup process is automated using a cron job configured in the Docker contai
5. Store the compressed dumps both locally (on your server or NAS) and offsite (on S3-compatible storage).

### Cleanup

The cleanup process is also automated using a cron job. It will:

1. Remove old backups based on the retention policy both onsite and offsite.

### Manual Trigger

You can manually trigger the backup and cleanup scripts inside the running container:

```sh
# Enter the running container
docker exec -it mysql-onsite-offsite-backup-backup-1 bash # Replace with your container name
docker exec -it mysql-onsite-offsite-backup_backup_1 bash

# Run backup script
bash /usr/local/bin/backup.bash
Expand All @@ -90,6 +92,7 @@ bash /usr/local/bin/cleanup.bash
```

## Configuration

The tool is configured via environment variables in the .env file. The following variables are required:

- MYSQL_USER: MySQL username
Expand All @@ -100,10 +103,12 @@ The tool is configured via environment variables in the .env file. The following
- S3_BUCKET_NAME: S3 bucket name
- S3_HOST_BASE: S3 host base URL
- S3_HOST_BUCKET: S3 host bucket URL pattern
- S3_BUCKET_LOCATION: S3 bucket location.
- S3_BUCKET_LOCATION: S3 bucket location
- DAILY_RETENTION: Number of daily backups to retain
- WEEKLY_RETENTION: Number of weekly backups to retain
- MONTHLY_RETENTION: Number of monthly backups to retain
- YEARLY_RETENTION: Number of yearly backups to retain

### Cron Schedule

The default cron schedule is set to run the backup and cleanup scripts at 2 AM daily (the server's local time). You can customize this by editing the crontab file in the project directory.

0 comments on commit 4401095

Please sign in to comment.