0

I'm running this script to backup a database. It works but I would like to add a secondary backup directory to get the output file in two different directories. Any help is appreciated..)

REM Set paths and database info
    set PGPASSWORD='postgre'
    set PGuser='postgres'
    set PGinstance='e3238s'
    set PGdump='F:/Program Files/PostgreSQL/9.5/bin\pg_dump'
    set BackupDir='F:/backup'
    set BackupName='DB_BK'

REM Build a datetime stamp
    set DateTime='%DATE:~-4%_%DATE:~-7,2%_%DATE:~-10,2%_%TIME:~0,2%_%TIME:~3,2% _%TIME:~6,2%'
echo %DateTime%

REM Backup 
    "%PGdump%" -f "%BackupDir%\%BackupName%%DateTime%.sql" --format plain -U %PGuser% -v %PGinstance%
Raviteja
  • 3,399
  • 23
  • 42
  • 69
Freddy S.
  • 1
  • 2

1 Answers1

0

This is quite unrelated to Postgres, and more related to how you'd output to two files in the same run.

You could use something like this, which in your case, becomes:

REM Backup 
    "%PGdump%" --format plain -U %PGuser% -v %PGinstance% >  "%BackupDir%\%BackupName%%DateTime%.sql" & type "%BackupDir%\%BackupName%%DateTime%.sql"  >> "%SecondaryBackupDir%\%BackupName%%DateTime%.sql" 
Community
  • 1
  • 1
Robins Tharakan
  • 2,209
  • 19
  • 17