37 lines
1.8 KiB
PowerShell
37 lines
1.8 KiB
PowerShell
|
|
# 서버에서 chandj 데이터베이스 다운로드 스크립트
|
||
|
|
# 사용법: .\download_db.ps1
|
||
|
|
|
||
|
|
$REMOTE_USER = "pro"
|
||
|
|
$REMOTE_HOST = "114.203.209.83"
|
||
|
|
$DB_NAME = "chandj"
|
||
|
|
$DB_USER = "codebridge" # 서버 DB 사용자 (필요시 변경)
|
||
|
|
$OUTPUT_FILE = "chandj_backup_$(Get-Date -Format 'yyyyMMdd_HHmmss').sql"
|
||
|
|
|
||
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
||
|
|
Write-Host "데이터베이스 덤프 다운로드 시작" -ForegroundColor Cyan
|
||
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
||
|
|
Write-Host "서버: $REMOTE_USER@$REMOTE_HOST" -ForegroundColor Yellow
|
||
|
|
Write-Host "데이터베이스: $DB_NAME" -ForegroundColor Yellow
|
||
|
|
Write-Host "출력 파일: $OUTPUT_FILE" -ForegroundColor Yellow
|
||
|
|
Write-Host ""
|
||
|
|
|
||
|
|
# 방법 1: SSH를 통해 직접 mysqldump 실행 (비밀번호 입력 필요)
|
||
|
|
Write-Host "방법 1: SSH를 통해 직접 덤프 다운로드" -ForegroundColor Green
|
||
|
|
Write-Host "명령어 실행 중..." -ForegroundColor Yellow
|
||
|
|
|
||
|
|
# SSH를 통해 mysqldump 실행하고 로컬 파일로 저장
|
||
|
|
ssh "$REMOTE_USER@$REMOTE_HOST" "mysqldump -u $DB_USER -p $DB_NAME" | Out-File -FilePath $OUTPUT_FILE -Encoding UTF8
|
||
|
|
|
||
|
|
if ($LASTEXITCODE -eq 0) {
|
||
|
|
Write-Host "✅ 덤프 다운로드 완료: $OUTPUT_FILE" -ForegroundColor Green
|
||
|
|
Write-Host "파일 크기: $((Get-Item $OUTPUT_FILE).Length / 1MB) MB" -ForegroundColor Cyan
|
||
|
|
} else {
|
||
|
|
Write-Host "❌ 덤프 다운로드 실패" -ForegroundColor Red
|
||
|
|
Write-Host ""
|
||
|
|
Write-Host "대안 방법:" -ForegroundColor Yellow
|
||
|
|
Write-Host "1. 서버에 SSH 접속" -ForegroundColor White
|
||
|
|
Write-Host "2. 다음 명령 실행: mysqldump -u $DB_USER -p $DB_NAME > /tmp/chandj_backup.sql" -ForegroundColor White
|
||
|
|
Write-Host "3. SFTP로 /tmp/chandj_backup.sql 파일 다운로드" -ForegroundColor White
|
||
|
|
}
|
||
|
|
|