59 lines
1.4 KiB
Markdown
59 lines
1.4 KiB
Markdown
# How to Sync Database from Server
|
|
|
|
## Quick Start
|
|
|
|
### Mac / Windows (WSL2 or Git Bash)
|
|
|
|
Run this single command from the project root:
|
|
|
|
```bash
|
|
./scripts/update-local-db-from-server.sh
|
|
```
|
|
|
|
That's it! Your local database now matches production.
|
|
|
|
> The script uses hardcoded defaults for `nvidia-admin@103.215.13.55`. To override, set environment variables before running.
|
|
|
|
## First Time Setup
|
|
|
|
1. Make sure Docker Desktop is running
|
|
2. Copy the docker override file:
|
|
```bash
|
|
cp docker-compose.override.local.example docker-compose.override.yml
|
|
```
|
|
3. Test SSH access:
|
|
```bash
|
|
ssh nvidia-admin@103.215.13.55
|
|
```
|
|
|
|
## What Each Script Does
|
|
|
|
- **`update-local-db-from-server.sh`** - Full sync (download + restore). Use this one.
|
|
- **`fetch-prod-db.sh`** - Only downloads backup to `./backups/`
|
|
- **`restore-postgres-local.sh`** - Only restores a backup file to local database
|
|
|
|
## Troubleshooting
|
|
|
|
**"Permission denied" error?**
|
|
|
|
- Make sure you can SSH: `ssh nvidia-admin@103.215.13.55`
|
|
|
|
**"docker: command not found"?**
|
|
|
|
- Start Docker Desktop
|
|
|
|
**Windows users:**
|
|
|
|
- Use WSL2, Git Bash, or PowerShell with WSL installed
|
|
- Run from the project root folder
|
|
|
|
## Pro Tip: Create an Alias
|
|
|
|
Add to `~/.zshrc` (Mac) or `~/.bashrc` (Windows/Linux):
|
|
|
|
```bash
|
|
alias sync-db='./scripts/update-local-db-from-server.sh'
|
|
```
|
|
|
|
Then from anywhere in the project, just type: `sync-db`
|