Files
mysql-bkup/docs/how-tos/backup-to-ftp.md

75 lines
2.2 KiB
Markdown
Raw Normal View History

2024-09-30 00:40:35 +02:00
---
title: Backup to FTP remote server
layout: default
parent: How Tos
nav_order: 4
---
2025-01-13 14:40:46 +01:00
# Backup to FTP Remote Server
2024-09-30 00:40:35 +02:00
2025-01-13 14:40:46 +01:00
To store your backups on an FTP remote server, you can configure the backup process to use the `--storage ftp` option.
2024-09-30 00:40:35 +02:00
2025-01-13 14:40:46 +01:00
This section explains how to set up and configure FTP-based backups.
2024-09-30 00:40:35 +02:00
2025-01-13 14:40:46 +01:00
---
## Configuration Steps
1. **Specify the Storage Type**
Add the `--storage ftp` flag to your backup command.
2. **Set the Remote Path**
Define the full remote path where backups will be stored using the `--path` flag or the `REMOTE_PATH` environment variable.
Example: `--path /home/jkaninda/backups`.
3. **Required Environment Variables**
The following environment variables are mandatory for FTP-based backups:
- `FTP_HOST`: The hostname or IP address of the FTP server.
- `FTP_PORT`: The FTP port (default is `21`).
- `FTP_USER`: The username for FTP authentication.
- `FTP_PASSWORD`: The password for FTP authentication.
- `REMOTE_PATH`: The directory on the FTP server where backups will be stored.
---
## Example Configuration
Below is an example `docker-compose.yml` configuration for backing up to an FTP remote server:
```yaml
2024-09-30 00:40:35 +02:00
services:
mysql-bkup:
2025-01-13 14:40:46 +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.
2024-09-30 00:40:35 +02:00
image: jkaninda/mysql-bkup
container_name: mysql-bkup
command: backup --storage ftp -d database
environment:
- DB_PORT=3306
2025-01-13 14:40:46 +01:00
- DB_HOST=mysql
2024-09-30 00:40:35 +02:00
- DB_NAME=database
- DB_USERNAME=username
- DB_PASSWORD=password
2025-01-13 14:40:46 +01:00
## FTP Configuration
- FTP_HOST="hostname"
2024-09-30 00:40:35 +02:00
- FTP_PORT=21
- FTP_USER=user
- FTP_PASSWORD=password
- REMOTE_PATH=/home/jkaninda/backups
2025-01-13 14:40:46 +01:00
# Ensure the mysql-bkup container is connected to the same network as your database
2024-09-30 00:40:35 +02:00
networks:
- web
2025-01-13 14:40:46 +01:00
2024-09-30 00:40:35 +02:00
networks:
web:
2025-01-13 14:40:46 +01:00
```
---
## Key Notes
- **Security**: FTP transmits data, including passwords, in plaintext. For better security, consider using SFTP (SSH File Transfer Protocol) or FTPS (FTP Secure) if supported by your server.
- **Remote Path**: Ensure the `REMOTE_PATH` directory exists on the FTP server and is writable by the specified `FTP_USER`.