From 93efd6ff39f038a288aa21b6c7b03fea991e19be Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 20 Apr 2008 05:44:54 +0000 Subject: * Added some more fixes, refactored SVNModule slightly. --- .../Modules/SvnSerialiser/SvnBackupModule.cs | 43 ++++++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs b/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs index 022755b..f6a98ac 100644 --- a/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs +++ b/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs @@ -30,6 +30,29 @@ namespace OpenSim.Region.Modules.SvnSerialiser public void SaveRegion(Scene scene) { + List svnfilenames = CreateAndAddExport(scene); + + m_svnClient.Commit3(svnfilenames, true, false); + m_log.Info("[SVNBACKUP]: Region backup successful (" + scene.RegionInfo.RegionName + ")."); + } + + public void SaveAllRegions() + { + List svnfilenames = new List(); + List regions = new List(); + + foreach (Scene scene in m_scenes) + { + svnfilenames.AddRange(CreateAndAddExport(scene)); + regions.Add("'" + scene.RegionInfo.RegionName + "' "); + } + + m_svnClient.Commit3(svnfilenames, true, false); + m_log.Info("[SVNBACKUP]: Server backup successful ( " + String.Concat(regions.ToArray()) + ")."); + } + + private List CreateAndAddExport(Scene scene) + { m_log.Info("[SVNBACKUP]: Saving a region to SVN with name " + scene.RegionInfo.RegionName); List filenames = m_serialiser.SerialiseRegion(scene, m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString() + "\\"); @@ -45,8 +68,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser svnfilenames.Add(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString() + Slash.DirectorySeparatorChar + filename); svnfilenames.Add(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString()); - m_svnClient.Commit3(svnfilenames, true, false); - m_log.Info("[SVNBACKUP]: Region backup successful (" + scene.RegionInfo.RegionName + ")."); + return svnfilenames; } public void LoadRegion(Scene scene) @@ -103,15 +125,16 @@ namespace OpenSim.Region.Modules.SvnSerialiser if (!commitItems.IsNull) { foreach (SvnClientCommitItem2 item in commitItems) - { - m_log.Debug("[SVNBACKUP]: Updated " + item.Path.ToString() + " (" + item.Kind.ToString() + ") " + item.Revision.ToString()); - m_log.Debug("[SVNBACKUP]: " + item.Url.ToString() + " -> " + item.CopyFromUrl.ToString()); + { + m_log.Debug("[SVNBACKUP]: ... " + System.IO.Path.GetFileName(item.Path.ToString()) + " (" + item.Kind.ToString() + ") r" + item.Revision.ToString()); } } - m_log.Debug("[SVNBACKUP]: Appending log message."); + string msg = "Region Backup (" + System.Environment.MachineName + " at " + DateTime.UtcNow.ToString() + " UTC)"; + + m_log.Debug("[SVNBACKUP]: Saved with message: " + msg); - logMessage = new AprString("Automated Region Backup", pool); + logMessage = new AprString(msg, pool); tmpFile = new SvnPath(pool); return (SvnError.NoError); @@ -234,10 +257,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser private void SaveAllScenes() { - foreach (Scene scene in m_scenes) - { - SaveRegion(scene); - } + SaveAllRegions(); } public void PostInitialise() @@ -265,7 +285,6 @@ namespace OpenSim.Region.Modules.SvnSerialiser private void SetupSerialiser() { - if (m_scenes.Count > 0) m_serialiser = m_scenes[0].RequestModuleInterface(); } -- cgit v1.1