mirror of
https://github.com/jkaninda/mysql-bkup.git
synced 2026-01-22 12:29:02 +01:00
doc: reviewed docs
This commit is contained in:
@@ -5,45 +5,71 @@ parent: How Tos
|
||||
nav_order: 6
|
||||
---
|
||||
|
||||
# Restore database from S3 storage
|
||||
# Restore Database from S3 Storage
|
||||
|
||||
To restore the database, you need to add `restore` command and specify the file to restore by adding `--file store_20231219_022941.sql.gz`.
|
||||
To restore a MySQL database from a backup stored in S3, use the `restore` command and specify the backup file with the `--file` flag. The system supports the following file formats:
|
||||
|
||||
{: .note }
|
||||
It supports __.sql__,__.sql.gpg__ and __.sql.gz__,__.sql.gz.gpg__ compressed file.
|
||||
- `.sql` (uncompressed SQL dump)
|
||||
- `.sql.gz` (gzip-compressed SQL dump)
|
||||
- `.sql.gpg` (GPG-encrypted SQL dump)
|
||||
- `.sql.gz.gpg` (GPG-encrypted and gzip-compressed SQL dump)
|
||||
|
||||
### Restore
|
||||
---
|
||||
|
||||
```yml
|
||||
## Configuration Steps
|
||||
|
||||
1. **Specify the Backup File**: Use the `--file` flag to specify the backup file to restore.
|
||||
2. **Set the Storage Type**: Add the `--storage s3` flag to indicate that the backup is stored in S3.
|
||||
3. **Provide S3 Configuration**: Include the necessary AWS S3 credentials and configuration.
|
||||
4. **Provide Database Credentials**: Ensure the correct database connection details are provided.
|
||||
|
||||
---
|
||||
|
||||
## Example: Restore from S3 Configuration
|
||||
|
||||
Below is an example `docker-compose.yml` configuration for restoring a database from S3 storage:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
mysql-bkup:
|
||||
# In production, it is advised to lock your image tag to a proper
|
||||
# release version instead of using `latest`.
|
||||
# Check https://github.com/jkaninda/mysql-bkup/releases
|
||||
# for a list of available releases.
|
||||
# In production, lock your image tag to a specific release version
|
||||
# instead of using `latest`. Check https://github.com/jkaninda/mysql-bkup/releases
|
||||
# for available releases.
|
||||
image: jkaninda/mysql-bkup
|
||||
container_name: mysql-bkup
|
||||
command: restore --storage s3 -d my-database -f store_20231219_022941.sql.gz --path /my-custom-path
|
||||
volumes:
|
||||
- ./backup:/backup
|
||||
- ./backup:/backup # Mount the directory for local operations (if needed)
|
||||
environment:
|
||||
- DB_PORT=3306
|
||||
- DB_HOST=mysql
|
||||
- DB_NAME=database
|
||||
- DB_USERNAME=username
|
||||
- DB_PASSWORD=password
|
||||
## AWS configurations
|
||||
## AWS S3 Configuration
|
||||
- AWS_S3_ENDPOINT=https://s3.amazonaws.com
|
||||
- AWS_S3_BUCKET_NAME=backup
|
||||
- AWS_REGION="us-west-2"
|
||||
- AWS_REGION=us-west-2
|
||||
- AWS_ACCESS_KEY=xxxx
|
||||
- AWS_SECRET_KEY=xxxxx
|
||||
## In case you are using S3 alternative such as Minio and your Minio instance is not secured, you change it to true
|
||||
- AWS_DISABLE_SSL="false"
|
||||
- AWS_FORCE_PATH_STYLE="false"
|
||||
# mysql-bkup container must be connected to the same network with your database
|
||||
## Optional: Disable SSL for S3 alternatives like Minio
|
||||
- AWS_DISABLE_SSL=false
|
||||
## Optional: Enable path-style access for S3 alternatives like Minio
|
||||
- AWS_FORCE_PATH_STYLE=false
|
||||
# Ensure the pg-bkup container is connected to the same network as your database
|
||||
networks:
|
||||
- web
|
||||
|
||||
networks:
|
||||
web:
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Key Notes
|
||||
|
||||
- **Supported File Formats**: The restore process supports `.sql`, `.sql.gz`, `.sql.gpg`, and `.sql.gz.gpg` files.
|
||||
- **S3 Path**: Use the `--path` flag to specify the folder within the S3 bucket where the backup file is located.
|
||||
- **Encrypted Backups**: If the backup is encrypted with GPG, ensure the `GPG_PASSPHRASE` environment variable is set for automatic decryption.
|
||||
- **S3 Alternatives**: For S3-compatible storage like Minio, set `AWS_DISABLE_SSL` and `AWS_FORCE_PATH_STYLE` as needed.
|
||||
- **Network Configuration**: Ensure the `pg-bkup` container is connected to the same network as your database.
|
||||
Reference in New Issue
Block a user