Below code for restoring the database backup works when I run after manually creating the database_restore in postgresql. I want to use the -C option to create the target database. i.e. dumper = “”” “C:Program FilesPostgreSQL14binpg_restore” -h %s -p %s -U %s -C -d %s -v -F t %s “”” instead. But this gives error. Any directions will be helpful.
os.putenv('PGPASSWORD', password)
from_backup_dir = ".\Files\DBBackups\"
dumper = """ "C:\Program Files\PostgreSQL\14\bin\pg_restore" -h %s -p %s -U %s -d %s -v -F t %s """
file_name = "dbbackup" + file_timestamp + ".backup"
command = dumper % (host, port, user, database_restore,
from_backup_dir + "dbbackup2024_07_31_16_00_29_859387.backup")