Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Hsu <kennethhsu@gmail.com>2018-03-04 23:29:56 +0300
committerKenneth Hsu <kennethhsu@gmail.com>2018-03-17 05:32:50 +0300
commite2aa98fbca889c5e02f17557db6b4e696b0ed5a6 (patch)
tree9687290d4a66df59dc06bd8fd6379c71806d735a /Duplicati/Server/Scheduler.cs
parent883922e2f3437ddffc9321dca097a9515ece0171 (diff)
Add option to disable backup when on battery power.
This addresses issue #2666.
Diffstat (limited to 'Duplicati/Server/Scheduler.cs')
-rw-r--r--Duplicati/Server/Scheduler.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/Duplicati/Server/Scheduler.cs b/Duplicati/Server/Scheduler.cs
index 41325f70a..44b53ed8d 100644
--- a/Duplicati/Server/Scheduler.cs
+++ b/Duplicati/Server/Scheduler.cs
@@ -34,6 +34,8 @@ namespace Duplicati.Server
/// </summary>
public class Scheduler
{
+ private static readonly string LOGTAG = Duplicati.Library.Logging.Log.LogTagFromType<Scheduler>();
+
/// <summary>
/// The thread that runs the scheduler
/// </summary>
@@ -278,7 +280,18 @@ namespace Duplicati.Server
{
var entry = Program.DataConnection.GetBackup(id);
if (entry != null)
- jobsToRun.Add(Server.Runner.CreateTask(Duplicati.Server.Serialization.DuplicatiOperation.Backup, entry));
+ {
+ Dictionary<string, string> options = Duplicati.Server.Runner.GetCommonOptions(entry, Duplicati.Server.Serialization.DuplicatiOperation.Backup);
+ Duplicati.Server.Runner.ApplyOptions(entry, Duplicati.Server.Serialization.DuplicatiOperation.Backup, options);
+ if ((new Duplicati.Library.Main.Options(options)).DisableOnBattery && (Duplicati.Library.Utility.Power.PowerSupply.GetSource() == Duplicati.Library.Utility.Power.PowerSupply.Source.Battery))
+ {
+ Duplicati.Library.Logging.Log.WriteInformationMessage(LOGTAG, "BackupDisabledOnBattery", "Scheduled backup disabled while on battery power.");
+ }
+ else
+ {
+ jobsToRun.Add(Server.Runner.CreateTask(Duplicati.Server.Serialization.DuplicatiOperation.Backup, entry));
+ }
+ }
}
}