MsSqlBackup 1.0.3

dotnet add package MsSqlBackup --version 1.0.3                
NuGet\Install-Package MsSqlBackup -Version 1.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MsSqlBackup" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MsSqlBackup --version 1.0.3                
#r "nuget: MsSqlBackup, 1.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MsSqlBackup as a Cake Addin
#addin nuget:?package=MsSqlBackup&version=1.0.3

// Install MsSqlBackup as a Cake Tool
#tool nuget:?package=MsSqlBackup&version=1.0.3                

Ms Sql Backup dotNet

Tiny DAO utility that backs up any Ms Sql Db (any edition) to a local or network drive and execute maintenance plans

Interfaces

IMsSqlBackupCreator

The nuGet has several methods all in three modes sync, async and pure background.

using System;
using System.Threading.Tasks;

namespace pvWay.MsSqlBackup
{
    public interface IMsSqlBackupCreator
    {
        /// <summary>
        /// Creates a full backup of the database
        /// </summary>
        /// <param name="bakFileName">Fully qualified backup file name where the running app has write access</param>
        /// <returns>IResult</returns>
        Task<IResult> BackupDbAsync(string bakFileName);

        /// <summary>
        /// Creates a full backup of the database
        /// </summary>
        /// <param name="bakFileName">Fully qualified backup file name where the running app has write access</param>
        /// <returns>IResult</returns>
        IResult BackupDb(string bakFileName);

        /// <summary>
        /// Creates a full backup of the database in background
        /// </summary>
        /// <param name="bakFileName">Fully qualified backup file name where the running app has write access</param>
        /// <param name="callback">A method that will be called on completion</param>
        /// <returns>void</returns>
        void BgBackupDb(string bakFileName, Action<IResult> callback);

        /// <summary>
        /// (1) finds the last backup file in the &lt;backupDestinationFolder&gt;
        /// by looking to files beginning with &lt;backupFilePrefix&gt; and ending with '.bak'
        /// (2) gets the last backup file modification time.
        /// (3) gets the elapsed time since this last backup.
        /// (4) if no file were found or elapsed time is greater
        /// than &lt;backupInterval&gt; then creates a new backup
        /// with a constructed file name
        /// &lt;backupFilePrefix&gt;_&lt;yyyyMMdd_HHmmss&gt;.bak;
        /// and save this new backup file into the &lt;backupDestinationFolder&gt;
        /// </summary>
        /// <param name="backupDestinationFolder"></param>
        /// <param name="backupFilePrefix"></param>
        /// <param name="backupInterval"></param>
        /// <returns>IExecuteMaintenancePlanResult</returns>
        Task<IExecuteMaintenancePlanResult> ExecuteMaintenancePlanAsync(
            string backupDestinationFolder,
            string backupFilePrefix,
            TimeSpan backupInterval);

        /// <summary>
        /// (1) finds the last backup file in the &lt;backupDestinationFolder&gt;
        /// by looking to files beginning with &lt;backupFilePrefix&gt; and ending with '.bak'
        /// (2) gets the last backup file modification time.
        /// (3) gets the elapsed time since this last backup.
        /// (4) if no file were found or elapsed time is greater
        /// than &lt;backupInterval&gt; then creates a new backup
        /// with a constructed file name
        /// &lt;backupFilePrefix&gt;_&lt;yyyyMMdd_HHmmss&gt;.bak;
        /// and save this new backup file into the &lt;backupDestinationFolder&gt;
        /// </summary>
        /// <param name="backupDestinationFolder">the folder where all backup files reside</param>
        /// <param name="backupFilePrefix"></param>
        /// <param name="backupInterval"></param>
        /// <returns>IExecuteMaintenancePlanResult</returns>
        IExecuteMaintenancePlanResult ExecuteMaintenancePlan(
            string backupDestinationFolder,
            string backupFilePrefix,
            TimeSpan backupInterval);

        /// <summary>
        /// Performs the following task in background and callbacks on completion:
        /// (1) finds the last backup file in the &lt;backupDestinationFolder&gt;
        /// by looking to files beginning with &lt;backupFilePrefix&gt; and ending with '.bak'
        /// (2) gets the last backup file modification time.
        /// (3) gets the elapsed time since this last backup.
        /// (4) if no file were found or elapsed time is greater
        /// than &lt;backupInterval&gt; then creates a new backup
        /// with a constructed file name
        /// &lt;backupFilePrefix&gt;_&lt;yyyyMMdd_HHmmss&gt;.bak;
        /// and save this new backup file into the &lt;backupDestinationFolder&gt;
        /// </summary>
        /// <param name="backupDestinationFolder"></param>
        /// <param name="backupFilePrefix"></param>
        /// <param name="backupInterval"></param>
        /// <param name="callback"></param>
        /// <returns>IExecuteMaintenancePlanResult</returns>
        void BgExecuteMaintenancePlan(
            string backupDestinationFolder,
            string backupFilePrefix,
            TimeSpan backupInterval,
            Action<IExecuteMaintenancePlanResult> callback);

    }
}

return values

using System;

namespace pvWay.MsSqlBackup.Core
{
    public interface IResult
    {
        bool Success { get; }
        bool Failure { get; }
        Exception Exception { get; }
    }

    public interface IExecuteMaintenancePlanResult : IResult
    {
        bool BackupCreated { get; }
        string BackupFileName { get; }
    }

}

Happy Coding

Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 583 8/27/2020
1.0.2 417 8/26/2020
1.0.0 537 8/24/2020 1.0.0 is deprecated because it has critical bugs.

Added Maintenance Plans, MethodResultWrapper removed