Dynamic Blinkie Text Generator at TextSpace.net

Feedburner

I heart FeedBurner

Jumat, 01 Desember 2017

Backup Data Otomatis dengan Bat File

Script :
SET PGPATH="C:\Program Files\PostgreSQL\9.5\bin\"
SET SVPATH="F:\project\jpa\coca_cola\database\backup_automatic\hasil\"
SET ALTPTH="C:\Users\fuckingshit\Documents\db_backupalt"
SET PRJDB=cocacola_suj
SET DBUSR=postgres


REM This is an ugly solution to get a timestamp for the newly created
REM dump file.

FOR /F "TOKENS=2,3,4 DELIMS=/ " %%i IN ('DATE /T') DO SET d=%%k-%%i-%%j
FOR /F "TOKENS=1,2,3 DELIMS=: " %%i IN ('TIME /T') DO SET t=%%i%%j%%k

SET DBDUMP=%PRJDB%-%d%-%t%.sql

%PGPATH%pg_dump.exe -C -U %DBUSR% %PRJDB% > %SVPATH%%DBDUMP%
copy %SVPATH%%DBDUMP% %ALTPTH%

atau  :
@ECHO OFF
@setlocal enableextensions
@cd /d "%~dp0"

SET PGPATH=C:\"Program Files"\PostgreSQL\9.5\bin\
SET SVPATH=F:\project\jpa\coca_cola\database\backup_automatic\hasil\
SET PRJDB=cocacola_suj
SET DBUSR=postgres
FOR /F "TOKENS=1,2,3 DELIMS=/ " %%i IN ('DATE /T') DO SET d=%%i-%%j-%%k
FOR /F "TOKENS=1,2,3 DELIMS=: " %%i IN ('TIME /T') DO SET t=%%i%%j%%k

SET DBDUMP=%PRJDB%_%d%_%t%.sql
@ECHO OFF
%PGPATH%pg_dump -h localhost -p 5432 -U postgres %PRJDB% > %SVPATH%%DBDUMP%

echo Backup Taken Complete %SVPATH%%DBDUMP%

Save as file .bat

Sumber : https://www.postgresql.org/message-id/363397.71757.qm%40web31814.mail.mud.yahoo.com

Tidak ada komentar:

Posting Komentar