add PowerShell script for database backups and include restore instructions in docker-compose.yml.

This commit is contained in:
Alaguraj0361 2026-01-20 21:31:09 +05:30
parent 623a38d672
commit 2d0f11526d
2 changed files with 33 additions and 1 deletions

25
backup_db.ps1 Normal file
View File

@ -0,0 +1,25 @@
# Odoo Database Backup Script
# This script dumps the Postgres database from the Docker container
# 1. Create backup directory if it doesn't exist
$BackupDir = "d:\Odoo\backups"
if (!(Test-Path -Path $BackupDir)) {
New-Item -ItemType Directory -Path $BackupDir
}
# 2. Define Backup Filename with Timestamp
$Date = Get-Date -f 'yyyy-MM-dd_HHmm'
$Filename = "db_backup_$Date.sql"
$FullPaths = Join-Path -Path $BackupDir -ChildPath $Filename
Write-Host "Starting backup to $FullPaths..." -ForegroundColor Cyan
# 3. Execute pg_dump inside the container
# We use --clean to include 'DROP TABLE' statements for easier restoration
docker exec odoo_client1_db pg_dump -U odoo -d postgres --clean > $FullPaths
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Backup successfully created: $Filename" -ForegroundColor Green
} else {
Write-Host "❌ Backup failed! Please ensure docker-compose is running." -ForegroundColor Red
}

View File

@ -31,4 +31,11 @@ services:
volumes:
client1_pgdata:
client1_odoo_data:
client1_odoo_data:
# backups:
# .\backup_db.ps1
# Team Members Restore
# cat d:\Odoo\backups\YOUR_BACKUP_FILE.sql | docker exec -i odoo_client1_db psql -U odoo -d postgres