Add sequential auto backup option

This commit is contained in:
Dave 2023-06-08 11:10:26 +02:00
parent 40d15dc74f
commit e56e9874a8
4 changed files with 74 additions and 12 deletions

View file

@ -1402,7 +1402,37 @@ namespace ServerManagerTool {
this["AutoBackup_BackupPeriod"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool AutoBackup_ParallelBackup
{
get
{
return ((bool)(this["AutoBackup_ParallelBackup"]));
}
set
{
this["AutoBackup_ParallelBackup"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("10")]
public int AutoBackup_SequencialDelayPeriod
{
get
{
return ((int)(this["AutoBackup_SequencialDelayPeriod"]));
}
set
{
this["AutoBackup_SequencialDelayPeriod"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]

View file

@ -657,6 +657,10 @@
<sys:String x:Key="GlobalSettings_ParallelUpdateTooltip">If enabled, when the auto-update is performed all servers will be updated at the same time, otherwise each server will be updated one after the other (this will take more time to complete).</sys:String>
<sys:String x:Key="GlobalSettings_SequencialDelayPeriodLabel">Delay between each server update</sys:String>
<sys:String x:Key="GlobalSettings_SequencialDelayPeriodTooltip">The amount of time to wait in between each server update, only available if Parallel Update is disabled.</sys:String>
<sys:String x:Key="GlobalSettings_ParallelBackupLabel">Backup servers in parallel</sys:String>
<sys:String x:Key="GlobalSettings_ParallelBackupTooltip">If enabled, when the auto-backup is performed all servers will be backup at the same time, otherwise each server will be backup one after the other (this could produce less server lags).</sys:String>
<sys:String x:Key="GlobalSettings_AutoBacckupSequencialDelayPeriodLabel">Delay between each server backup</sys:String>
<sys:String x:Key="GlobalSettings_AutoBackupSequencialDelayPeriodTooltip">The amount of time to wait in between each server backup, only available if Parallel Backup is disabled.</sys:String>
<sys:String x:Key="GlobalSettings_AutoRestartLabel">Auto Restart Options</sys:String>
<sys:String x:Key="GlobalSettings_RestartGraceIntervalInformationLabel">The grace period does not prevent auto-updates from restarting your server.</sys:String>

View file

@ -3391,18 +3391,43 @@ namespace ServerManagerTool.Lib
var profiles = _profiles.Keys.Where(p => p.EnableAutoBackup);
var exitCodes = new ConcurrentDictionary<ServerProfileSnapshot, int>();
Parallel.ForEach(profiles, profile => {
var app = new ServerApp
if (Config.Default.AutoBackup_ParallelBackup)
{
Parallel.ForEach(profiles, profile => {
var app = new ServerApp
{
DeleteOldBackupFiles = Config.Default.AutoBackup_DeleteOldFiles,
OutputLogs = true,
SendAlerts = true,
SendEmails = true,
ServerProcess = ServerProcessType.AutoBackup
};
app.PerformProfileBackup(profile, CancellationToken.None);
exitCodes.TryAdd(profile, app.ExitCode);
});
}
else
{
var delay = 0;
foreach (ServerProfileSnapshot profile in profiles)
{
DeleteOldBackupFiles = Config.Default.AutoBackup_DeleteOldFiles,
OutputLogs = true,
SendAlerts = true,
SendEmails = true,
ServerProcess = ServerProcessType.AutoBackup
};
app.PerformProfileBackup(profile, CancellationToken.None);
exitCodes.TryAdd(profile, app.ExitCode);
});
if (delay > 0)
Task.Delay(delay * 1000).Wait();
delay = Math.Max(0, Config.Default.AutoBackup_SequencialDelayPeriod);
var app = new ServerApp
{
DeleteOldBackupFiles = Config.Default.AutoBackup_DeleteOldFiles,
OutputLogs = true,
SendAlerts = true,
SendEmails = true,
ServerProcess = ServerProcessType.AutoBackup
};
app.PerformProfileBackup(profile, CancellationToken.None);
exitCodes.TryAdd(profile, app.ExitCode);
}
}
foreach (var profile in _profiles.Keys)
{

View file

@ -419,6 +419,9 @@
<Binding Path="Config.AutoBackup_BackupPeriod" Converter="{StaticResource MinutesToTimeValueConverter}"/>
</TextBox.Text>
</TextBox>
<CheckBox Grid.Row="3" Grid.Column="0" Margin="5,2,0,2" Grid.ColumnSpan="2" Content="{DynamicResource GlobalSettings_ParallelBackupLabel}" IsChecked="{Binding Config.AutoBackup_ParallelBackup, Mode=TwoWay}" ToolTip="{DynamicResource GlobalSettings_ParallelBackupTooltip}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<cctl:AnnotatedSlider Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="3" Margin="0,2,0,2" Label="{DynamicResource GlobalSettings_AutoBacckupSequencialDelayPeriodLabel}" Value="{Binding Config.AutoBackup_SequencialDelayPeriod}" Minimum="0" Maximum="1200" SmallChange="1" LargeChange="2" TickFrequency="5" LabelRelativeWidth="Auto" SliderRelativeWidth="15*" SuffixRelativeWidth="Auto" Suffix="{DynamicResource SliderUnits_Seconds}" ToolTip="{DynamicResource GlobalSettings_AutoBackupSequencialDelayPeriodTooltip}" IsEnabled="{Binding Config.AutoBackup_ParallelBackup, Converter={StaticResource InvertBooleanConverter}}"/>
</Grid>
</GroupBox>