Mẹo vặt Sói's Tutorials

Note tạo cronjob backup PostgreSQL Database

Cronjob backup cmd bat file Save sql

@ECHO OFF “C:\Program Files\PostgreSQL\9.3\bin\pg_dump.exe” -p 5432 -U postgres “clone7” > “D:\backupdb\ladb.sql”
Copy file
@echo off for /f “delims=” %%a in (‘wmic OS Get localdatetime  ^| find “.”‘) do set dt=%%a set YYYY=%dt:~0,4% set MM=%dt:~4,2% set DD=%dt:~6,2% set HH=%dt:~8,2% set Min=%dt:~10,2% set Sec=%dt:~12,2% set stamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec% copy “D:\backupdb\ladb.sql” “D:\backupdb\abc\ladb – %stamp%.sql”
  Lưu lại thành file bat rồi đặt lịch trong Window thôi.]]>

Leave a Reply

Your email address will not be published. Required fields are marked *