BacupFunctionality
This commit is contained in:
22
SqliteBackups/BackupRoutines.cs
Normal file
22
SqliteBackups/BackupRoutines.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using SqliteBackups.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SQLite;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqliteBackups
|
||||
{
|
||||
public class BackupRoutines : IBackupRoutines
|
||||
{
|
||||
public void BackupSqliteDb(string fromDb, string toDb)
|
||||
{
|
||||
using var source = new SQLiteConnection($"Data Source={fromDb}; Version=3;");
|
||||
using var destination = new SQLiteConnection($"Data Source={toDb}; Version=3;");
|
||||
source.Open();
|
||||
destination.Open();
|
||||
source.BackupDatabase(destination, "main", "main", -1, null, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
SqliteBackups/Interfaces/IBackupRoutines.cs
Normal file
13
SqliteBackups/Interfaces/IBackupRoutines.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqliteBackups.Interfaces
|
||||
{
|
||||
public interface IBackupRoutines
|
||||
{
|
||||
void BackupSqliteDb(string fromDb, string toDb);
|
||||
}
|
||||
}
|
||||
11
SqliteBackups/SqliteBackups.csproj
Normal file
11
SqliteBackups/SqliteBackups.csproj
Normal file
@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Data.SQLite" Version="1.0.113.7" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user