Files
mysql-bkup/docs/how-tos/restore.md

65 lines
1.8 KiB
Markdown
Raw Normal View History

---
title: Restore database
layout: default
parent: How Tos
2024-09-30 00:40:35 +02:00
nav_order: 5
---
2025-01-13 14:56:08 +01:00
# Restore Database
2025-01-13 14:56:08 +01:00
To restore a MySQL database, use the `restore` command and specify the backup file to restore with the `--file` flag.
2025-01-13 14:56:08 +01:00
The system supports the following file formats:
2025-01-13 14:56:08 +01:00
- `.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)
---
## Configuration Steps
1. **Specify the Backup File**: Use the `--file` flag to specify the backup file to restore.
2. **Provide Database Credentials**: Ensure the correct database connection details are provided.
---
## Example: Restore Configuration
Below is an example `docker-compose.yml` configuration for restoring a database:
```yaml
services:
mysql-bkup:
2025-01-13 14:56:08 +01:00
# 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
2024-08-10 10:50:00 +02:00
command: restore -d database -f store_20231219_022941.sql.gz
volumes:
2025-01-13 14:56:08 +01:00
- ./backup:/backup # Mount the directory containing the backup file
environment:
- DB_PORT=3306
2025-01-13 14:56:08 +01:00
- DB_HOST=postgres
- DB_NAME=database
- DB_USERNAME=username
- DB_PASSWORD=password
2025-01-13 14:56:08 +01:00
# Ensure the pg-bkup container is connected to the same network as your database
networks:
- web
2025-01-13 14:56:08 +01:00
networks:
web:
2025-01-13 14:56:08 +01:00
```
---
## Key Notes
- **Supported File Formats**: The restore process supports `.sql`, `.sql.gz`, `.sql.gpg`, and `.sql.gz.gpg` files.
- **Encrypted Backups**: If the backup is encrypted with GPG, ensure the `GPG_PASSPHRASE` environment variable is set for automatic decryption.
- **Network Configuration**: Ensure the `mysql-bkup` container is connected to the same network as your database.