SafeDispatch/SafeMobileLIB_DLL/Failover/RollBackFiles.cs

58 lines
1.6 KiB
C#
Raw Permalink Normal View History

2024-02-22 16:43:59 +00:00
using SafeMobileLib;
using System;
using System.IO;
namespace SafeMobileLib
{
public class RollBackFiles
{
public static void MovePostgresql(string path)
{
string destinationFile = path + @"\postgresql\SafeDB\postgresql.conf";
string sourceFile = path + @"\postgresql\SafeDB\backupReplication\postgresql.conf";
MoveFile(sourceFile, destinationFile);
}
public static void MoveHba(string path)
{
string destinationFile = path + @"\postgresql\SafeDB\pg_hba.conf";
string sourceFile = path + @"\postgresql\SafeDB\backupReplication\pg_hba.conf";
MoveFile(sourceFile, destinationFile);
}
public static void MoveFile(string sourceFile, string destinationFile)
{
if (File.Exists(destinationFile))
File.Delete(destinationFile);
// move the file
File.Move(sourceFile, destinationFile);
// Show the file content to console.
string readText = File.ReadAllText(destinationFile);
Console.WriteLine(readText);
Utils.WriteLine("File successfuly written to: " + destinationFile, ConsoleColor.DarkCyan);
}
public static void DeleteRecovery(string path)
{
string sourceFile = path + @"\postgresql\SafeDB\recovery.conf";
if (File.Exists(sourceFile))
{
File.Delete(sourceFile);
Utils.WriteLine("recovery.conf DELETED!!!", ConsoleColor.DarkCyan);
}
}
}
}