private void DoBackup(object o)
{
try
{
string worldname = Main.worldPathName;
string name = Path.GetFileName(worldname);
Main.worldPathName = Path.Combine(BackupPath, string.Format("{0}.{1:dd.MM.yy-HH.mm.ss}.bak", name, DateTime.UtcNow));
string worldpath = Path.GetDirectoryName(Main.worldPathName);
if (worldpath != null && !Directory.Exists(worldpath))
Directory.CreateDirectory(worldpath);
if (TShock.Config.ShowBackupAutosaveMessages)
{
TSPlayer.All.SendInfoMessage("Server map saving, potential lag spike.");
}
Console.WriteLine("Backing up world...");
SaveManager.Instance.SaveWorld();
Console.WriteLine("World backed up.");
Console.ForegroundColor = ConsoleColor.Gray;
TShock.Log.Info(string.Format("World backed up ({0}).", Main.worldPathName));
Main.worldPathName = worldname;
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Backup failed!");
Console.ForegroundColor = ConsoleColor.Gray;
TShock.Log.Error("Backup failed!");
TShock.Log.Error(ex.ToString());
}
}