122 lines
4.1 KiB
Markdown
122 lines
4.1 KiB
Markdown
# Backup Tool
|
|
|
|
Backup Tool is a FastAPI and React application for managing local, SSH/SFTP, PostgreSQL, and MySQL backup sources. It provides backup jobs and executions, scheduling, retention policies, a web dashboard, and a REST API.
|
|
|
|
## Status and limitations
|
|
|
|
The backend package is versioned `0.1.0` and classified as beta. Runtime verification is outside this README; review the configuration and test commands below before using the application for production backups.
|
|
|
|
The Compose configuration sets `BACKUP_STORAGE_PATH=/app/backups`, but the current Python application does not read that environment variable. The `/app/backups` volume is still mounted by Compose; the application's effective use of that path is not verified here.
|
|
|
|
## Prerequisites
|
|
|
|
- Docker with Docker Compose for the containerized setup.
|
|
- Python 3.11 or newer for manual backend development.
|
|
- Node.js for manual frontend development. The development Compose service uses Node 20 Alpine; no standalone Node version is declared by the frontend package.
|
|
|
|
## Run with Docker Compose
|
|
|
|
From the repository root:
|
|
|
|
```bash
|
|
# Backend only
|
|
docker compose up -d
|
|
|
|
# Backend plus the production frontend
|
|
docker compose --profile prod up -d
|
|
|
|
# Backend plus the Vite development frontend
|
|
docker compose --profile dev up -d
|
|
```
|
|
|
|
The backend is published at <http://localhost:8000>; its OpenAPI documentation is at <http://localhost:8000/docs>. Either frontend profile publishes the frontend at <http://localhost:3000>.
|
|
|
|
Compose persists the SQLite data directory in `backup-data` and the backup directory in `backup-storage`. The backend health check requests `/api/health`.
|
|
|
|
## Manual development
|
|
|
|
### Backend
|
|
|
|
```bash
|
|
cd backend
|
|
python -m venv venv
|
|
source venv/bin/activate
|
|
pip install -e ".[dev]"
|
|
uvicorn app.main:app --reload --port 8000
|
|
```
|
|
|
|
The backend requires Python 3.11+. Its default `DATABASE_URL` is `sqlite+aiosqlite:///./backup_tool.db`.
|
|
|
|
### Frontend
|
|
|
|
```bash
|
|
cd frontend
|
|
npm install
|
|
npm run dev
|
|
```
|
|
|
|
To build the frontend for the backend to serve:
|
|
|
|
```bash
|
|
cd frontend
|
|
npm run build
|
|
```
|
|
|
|
When `frontend/dist` exists, the backend mounts its assets and serves the SPA fallback. For a manually built frontend and backend, start the backend as above (or bind explicitly with `uvicorn app.main:app --host 0.0.0.0 --port 8000`).
|
|
|
|
## Configuration
|
|
|
|
The backend reads these environment variables:
|
|
|
|
| Variable | Purpose | Default |
|
|
| --- | --- | --- |
|
|
| `DATABASE_URL` | SQLAlchemy database URL | `sqlite+aiosqlite:///./backup_tool.db` |
|
|
| `SQL_ECHO` | Enable SQL query logging when `true` | `false` |
|
|
| `CORS_ORIGINS` | Comma-separated allowed origins | `http://localhost:3000` |
|
|
|
|
Compose supplies a SQLite URL under `/app/data`, `CORS_ORIGINS=http://localhost:3000`, and mounts persistent data and backup volumes. Configure credentials for backup sources through the application rather than committing them to the repository.
|
|
|
|
## Development and database operations
|
|
|
|
Run the backend tests:
|
|
|
|
```bash
|
|
cd backend
|
|
pytest
|
|
```
|
|
|
|
The frontend package defines `dev`, `build`, and `preview` scripts; it does not currently define a test script.
|
|
|
|
Alembic commands are available from `backend/`:
|
|
|
|
```bash
|
|
alembic revision --autogenerate -m "Description"
|
|
alembic upgrade head
|
|
```
|
|
|
|
## Deployment and operations
|
|
|
|
For the provided production frontend container, use:
|
|
|
|
```bash
|
|
docker compose --profile prod up -d
|
|
```
|
|
|
|
This starts the backend and an nginx-served frontend. For manual deployment, build the frontend and run the backend; the backend can serve `frontend/dist` when that directory exists. Choose and protect backup-source credentials, retention policies, and persistent storage for the environment.
|
|
|
|
## Repository layout
|
|
|
|
```text
|
|
.
|
|
├── backend/ # FastAPI application, backup engine, Alembic, and tests
|
|
│ └── pyproject.toml # Python dependencies and pytest configuration
|
|
├── frontend/ # React/Vite frontend
|
|
│ └── package.json # Frontend scripts and dependencies
|
|
├── docker-compose.yml # Backend and optional frontend profiles
|
|
└── docs/ # Project documentation
|
|
```
|
|
|
|
## License
|
|
|
|
MIT
|