PDA

View Full Version : Database Maintenance Batch files



Cusem
09-26-2008, 05:20 AM
I have the following batch commands which I used with PT2.
Can I run the same commands for the HM database? Or do I have to use different parameters (especially with the cluster batchfile)?

I run the batch files with the DBName as a paramater (for instance BACKUP.BAT HMPOSTGRESDBNAME)

I'm using PostgreSQL 8.3.x on WinXP x64


Backup
@echo off
echo Backing Up Database: %1
"C:\Program Files (x86)\PostgreSQL\8.2\bin\pg_dump.exe" -i -h localhost -p 5432 -U postgres -F c -v -f "F:\Backup\PokerTracker\%1 %date:~-7,2%-%date:~0,2%-%date:~-4,4%.backup" "%1"

Cluster
@echo off
echo Clustering %1%
echo Action 1: Recreating tables for %1 [cluster session_idx_02 on session]
"c:\program files (x86)\postgresql\8.2\bin\psql" -d "%1" -U postgres -c "cluster session_idx_02 on session;"
pause
echo Action 2: Recreating tables for %1 [cluster player_winnings_idx_02 on player_winnings]
"c:\program files (x86)\postgresql\8.2\bin\psql" -d "%1" -U postgres -c "cluster player_winnings_idx_02 on player_winnings;"
pause
echo Action 3: Recreating tables for %1 [cluster player_idx_02 on players]
"c:\program files (x86)\postgresql\8.2\bin\psql" -d "%1" -U postgres -c "cluster player_idx_02 on players;"
pause
echo Action 4: Recreating tables for %1 [cluster game_idx_01 on game]
"c:\program files (x86)\postgresql\8.2\bin\psql" -d "%1" -U postgres -c "cluster game_idx_01 on game;"
pause
echo Action 5: Recreating tables for %1 [cluster game_players_idx_05 on game_players]
"c:\program files (x86)\postgresql\8.2\bin\psql" -d "%1" -U postgres -c "cluster game_players_idx_05 on game_players;"
echo Finished!

Vacuum/Analyze
@echo off
echo Performing Vacuum Full/Analyze on all databases
"C:\Program Files (x86)\PostgreSQL\8.2\bin\vacuumdb.exe" -h localhost -p 5432 -U postgres -d %1 -f -z -v

Rvg72
09-27-2008, 02:24 AM
Hi, the clustering won't do anything so you can remove all of that but the backup and vacuum works

Roy