0

I'm creating a Windows Service application in c# to automate PostGreSql database backups. (With scheduled tasks to do full backups, clean old files, ...)

To do it, I first need to edit the postgresql.conf file, uncomment some parameters and change some values to enable Write-Ahead Logging ( WAL ).

I would like to do it automatically from my code. Is there a simple way or existing code to do it ?

I found this Linux script but I need to do it from C#...

Example of parameters to edit:

# - Archiving -                                       

archive_mode = on                          

archive_command = 'copy "%p" "C:\\Backups\\%f"'                            

archive_timeout = 600 # force a logfile segment switch after this number of seconds

Is there a standard name for this kind of configuration file ?

Gab
  • 1,861
  • 5
  • 26
  • 39

1 Answers1

1

Sounds like you want to open the file, do a "find & replace" then save the changes.

This is how you would do that. How to Find And Replace Text In A File With C#

Community
  • 1
  • 1
Jason Geiger
  • 1,912
  • 18
  • 32