aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-04-21 04:11:56 +0000
committerAdam Frisby2008-04-21 04:11:56 +0000
commit8cf42ddb8434b4df953217ba0fe0ebe1cbef7828 (patch)
tree981b3eea62043a318557fab24502ff414fecef94 /OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
parent* Extra log line to notify the user console when a new user inventory skeleto... (diff)
downloadopensim-SC-8cf42ddb8434b4df953217ba0fe0ebe1cbef7828.zip
opensim-SC-8cf42ddb8434b4df953217ba0fe0ebe1cbef7828.tar.gz
opensim-SC-8cf42ddb8434b4df953217ba0fe0ebe1cbef7828.tar.bz2
opensim-SC-8cf42ddb8434b4df953217ba0fe0ebe1cbef7828.tar.xz
* Added support for periodic autosaves - added to SvnBackupModule. Will cause a SVN revision to be saved every X minutes. (Default = 15)
* Added 'Autosave' options to OpenSim.ini.Example * Added 'ImportOnStartup' option to OpenSim.ini.example
Diffstat (limited to 'OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs')
-rw-r--r--OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs38
1 files changed, 30 insertions, 8 deletions
diff --git a/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs b/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
index f6a98ac..aaa7acf 100644
--- a/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
+++ b/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
@@ -23,11 +23,20 @@ namespace OpenSim.Region.Modules.SvnSerialiser
23 private string m_svnuser = "username"; 23 private string m_svnuser = "username";
24 private string m_svnpass = "password"; 24 private string m_svnpass = "password";
25 private string m_svndir = "SVNmodule\\repo"; 25 private string m_svndir = "SVNmodule\\repo";
26
27 private TimeSpan m_svnperiod = new TimeSpan(0, 0, 15, 0, 0);
28 private bool m_svnAutoSave = false;
29 private System.Timers.Timer m_timer = new System.Timers.Timer();
30
26 private IRegionSerialiser m_serialiser; 31 private IRegionSerialiser m_serialiser;
27 private List<Scene> m_scenes = new List<Scene>(); 32 private List<Scene> m_scenes = new List<Scene>();
28 33
29 #region SvnModule Core 34 #region SvnModule Core
30 35
36 /// <summary>
37 /// Exports a specified scene to the SVN repo directory, then commits.
38 /// </summary>
39 /// <param name="scene">The scene to export</param>
31 public void SaveRegion(Scene scene) 40 public void SaveRegion(Scene scene)
32 { 41 {
33 List<string> svnfilenames = CreateAndAddExport(scene); 42 List<string> svnfilenames = CreateAndAddExport(scene);
@@ -36,6 +45,9 @@ namespace OpenSim.Region.Modules.SvnSerialiser
36 m_log.Info("[SVNBACKUP]: Region backup successful (" + scene.RegionInfo.RegionName + ")."); 45 m_log.Info("[SVNBACKUP]: Region backup successful (" + scene.RegionInfo.RegionName + ").");
37 } 46 }
38 47
48 /// <summary>
49 /// Saves all registered scenes to the SVN repo, then commits.
50 /// </summary>
39 public void SaveAllRegions() 51 public void SaveAllRegions()
40 { 52 {
41 List<string> svnfilenames = new List<string>(); 53 List<string> svnfilenames = new List<string>();
@@ -158,6 +170,8 @@ namespace OpenSim.Region.Modules.SvnSerialiser
158 m_svnuser = source.Configs["SVN"].GetString("Username", m_svnuser); 170 m_svnuser = source.Configs["SVN"].GetString("Username", m_svnuser);
159 m_svnpass = source.Configs["SVN"].GetString("Password", m_svnpass); 171 m_svnpass = source.Configs["SVN"].GetString("Password", m_svnpass);
160 m_installBackupOnLoad = source.Configs["SVN"].GetBoolean("ImportOnStartup", m_installBackupOnLoad); 172 m_installBackupOnLoad = source.Configs["SVN"].GetBoolean("ImportOnStartup", m_installBackupOnLoad);
173 m_svnAutoSave = source.Configs["SVN"].GetBoolean("Autosave", m_svnAutoSave);
174 m_svnperiod = new TimeSpan(0, source.Configs["SVN"].GetInt("AutosavePeriod", (int)m_svnperiod.TotalMinutes), 0);
161 } catch(Exception) { } 175 } catch(Exception) { }
162 176
163 lock (m_scenes) 177 lock (m_scenes)
@@ -172,7 +186,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
172 { 186 {
173 if (args[0] == "svn" && args[1] == "save") 187 if (args[0] == "svn" && args[1] == "save")
174 { 188 {
175 SaveAllScenes(); 189 SaveAllRegions();
176 } 190 }
177 if (args.Length == 2) 191 if (args.Length == 2)
178 { 192 {
@@ -234,7 +248,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
234 m_log.Warn("[SVNBACKUP]: No region loaded - unable to find matching name."); 248 m_log.Warn("[SVNBACKUP]: No region loaded - unable to find matching name.");
235 } 249 }
236 250
237 private void LoadAllScenes() 251 public void LoadAllScenes()
238 { 252 {
239 CheckoutSvn(); 253 CheckoutSvn();
240 254
@@ -245,7 +259,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
245 } 259 }
246 260
247 261
248 private void LoadAllScenes(int revision) 262 public void LoadAllScenes(int revision)
249 { 263 {
250 CheckoutSvn(new SvnRevision(revision)); 264 CheckoutSvn(new SvnRevision(revision));
251 265
@@ -255,16 +269,19 @@ namespace OpenSim.Region.Modules.SvnSerialiser
255 } 269 }
256 } 270 }
257 271
258 private void SaveAllScenes()
259 {
260 SaveAllRegions();
261 }
262
263 public void PostInitialise() 272 public void PostInitialise()
264 { 273 {
265 if (m_enabled == false) 274 if (m_enabled == false)
266 return; 275 return;
267 276
277 if (m_svnAutoSave == true)
278 {
279 m_timer.Interval = m_svnperiod.TotalMilliseconds;
280 m_timer.Elapsed += new System.Timers.ElapsedEventHandler(m_timer_Elapsed);
281 m_timer.AutoReset = true;
282 m_timer.Start();
283 }
284
268 m_log.Info("[SVNBACKUP]: Connecting to SVN server " + m_svnurl + " ..."); 285 m_log.Info("[SVNBACKUP]: Connecting to SVN server " + m_svnurl + " ...");
269 SetupSvnProvider(); 286 SetupSvnProvider();
270 287
@@ -283,6 +300,11 @@ namespace OpenSim.Region.Modules.SvnSerialiser
283 } 300 }
284 } 301 }
285 302
303 void m_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
304 {
305 SaveAllRegions();
306 }
307
286 private void SetupSerialiser() 308 private void SetupSerialiser()
287 { 309 {
288 if (m_scenes.Count > 0) 310 if (m_scenes.Count > 0)