I am trying a bat file to backup my database using the below command:
pg_dump -h "localhost" -U "postgres" -f "D:\\Database\\Backup\\db_backup_%date:~-4%_%date:~3,2%_%date:~0,2%_%time:0,2%_%time:~3,2%_%time:~6,2%" "db_options"
However, I am getting the error:
D:\Database\Backup>pg_dump -h "localhost" -U "postgres" -f "D:\\Database\\Backup\\db_backup_2022_ 0_Mo_time:0,2time:~3,2time:~6,2" "db_options"
unrecognized win32 error code: 123pg_dump: error: could not open output file "D:\\Database\\Backup\\db_backup_2022_ 0_Mo_time:0,2time:~3,2time:~6,2": Invalid argument
What is the correct syntax to get batch file with date and timestamp?
e.g. db_backup_19092022-134600 (13:00 hrs, 46 mins 00 Secs)