Implementing a remote Linux backup plan with Dar and Rsync MV Blog code posting utility

MV Backup Server Safe Shutdown Monitor

Scenario: Windows server machine with one or more folders that daily receive backup files from different client machines, within a defined (and configurable) time interval, and after receiving all the archives from all client machines must be shutdown automatically.

MV Backup Server Safe Shutdown Monitor tray areaThis utility, written in C# .net, is made up by:

  • a Windows service, the "MV Backup Server Safe Shutdown - Service", so it can do its work even if no user is connected to the machine console;
  • a monitor software, the "MV Backup Server Safe Shutdown - Monitor", which resides in the Windows Tray Area, useful for the possible administrative tasks on the service, such as monitor state check, working parameters check, etc.

How it works

The service checks at regulars (configurable) time intervals every folder (including subfolders) under its control, to see if there are files on which the last modification date matches the current date. When it finds some files that satisfies this condition, it activates a short time check to detect any folder modification, so it can understand if the folder is under modification (for example because a file transfer is active) or not. When, after a short check, the folder appears unmodified from the last check, the MV Backup Server Safe Shutdow marks it as "complete". When all monitored folders have their status "complete", MV Backup Server Safe Shutdow raise a system shutdown action. The checks takes place only if the current time is in the detect_time_interval service parameter (see below).

 

Download MV Backup Server Safe Shutdown

Configuration

For simplicity all configuration options are set by editing the file BackupShutdownService.exe.config, that is located in the software installation folder (it can be accessed also from Start > All Programs> MV Backup Server Safe Shutdown > Edit service configuration. (Note: after editing the file, it is necessary to restart the MV Backup Server Safe Shutdown Service so that the new configuration becomes effective. Eventual problems or notifications are visible in the System Event Viewer - Application section).
If you are experiencing problems with automatic shutdown, please read this note.

The BackupShutdownService.exe.configfile is an XML file, the options to edit are all located below the line n.30 (which contains<BackupShutdownService.Properties.Settings>):

detect_time_interval - start_hour.start-minute-end_hour.end_minute
The check on monitored folders takes place daily only in this time interval, you must follow this format: xx.xx-xx.xx; For example: 01.00-05.00 or 22.00-03.00. See example file below, line 32
monitored_folders
Strings collection, one for each folder to be monitored. In the example configuration file there are 3 folders. See example file below, from line 38 to 40.
polling_interval (seconds)
Denotes how many often monitored folders must be checked, expressed in seconds. See example file below, line 45.
short_check_interval (seconds)
When the software detects changes in a monitored folder, it starts a dedicated control toward that folder, repeated every ’short_check_interval’ seconds, to monitor its eventual modifications, for example during a file transfer. It is reccomended to not modify this setting. See example file below, line 48.
shutdown_timeout (seconds)
Denotes after how many seconds from the "complete" status detection the system must be shutdown. This can be useful for saving opened files o to cancel the shutdown through the MV Backup Server Safe Shutdown Monitor. See example file below, line 51.
SMTP_server
Assigns the SMTP server to be used for email notification of raised shutdown events. See example file below, line 54.
SMTP_server_port
Assigns the SMTP server port. See example file below, line 57.
SMTP_useSSL
If your SMTP server allows SSL encryption, set it to True. See example file below, line 60.
SMTP_auth_user
To be used in conjunction with SMTP_useSSL, denotes the username to use for SMTP authentication. See example file below, line 63.
SMTP_auth_password
To be used in conjunction with SMTP_useSSL, denotes the password to use for SMTP authentication. See example file below, line 66.
notify_email_to
Email address to send notifications. See example file below, line 69.
notify_email_from
Sender email address used for notifications. See example file below, line 72.
debug_level
Verbose level. Accepted values: from 0 (less verbosity) a 3 (maximum verbosity). See example file below, line 75.

Hereafter is shown the default configuration file; lines to be edited start at line 30.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="BackupShutdownService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <appSettings>
    <add key="ServicePort"
    value="21744" />
  </appSettings>


  <system.runtime.remoting>
		<application name="EventsManagerHost"  >
			<service>
				<wellknown type="EventsManager.Hoster,EventsManager" objectUri="Connect" mode="Singleton" />
			</service>
			<channels>
				<channel ref="tcp" port="21744">
					<serverProviders>            
						<formatter ref="binary" typeFilterLevel="Full" />
					</serverProviders>					
				</channel>
			</channels>
		</application>
	</system.runtime.remoting>
  <applicationSettings>
    <BackupShutdownService.Properties.Settings>
      <setting name="detect_time_interval" serializeAs="String">
        <value>01.00-05.00</value>
      </setting>
      <setting name="monitored_folders" serializeAs="Xml">
        <value>
          <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <string>c:\test folder1</string>
            <string>c:\test folder2</string>
            <string>c:\test folder3</string>
          </ArrayOfString>
        </value>
      </setting>
      <setting name="polling_interval" serializeAs="String">
        <value>600</value>
      </setting>
      <setting name="short_check_interval" serializeAs="String">
        <value>20</value>
      </setting>
      <setting name="shutdown_timeout" serializeAs="String">
        <value>120</value>
      </setting>
      <setting name="SMTP_server" serializeAs="String">
        <value>localhost</value>
      </setting>
      <setting name="SMTP_server_port" serializeAs="String">
        <value>25</value>
      </setting>
      <setting name="SMTP_useSSL" serializeAs="String">
        <value>False</value>
      </setting>
      <setting name="SMTP_auth_user" serializeAs="String">
        <value>you@yourmailserver.com</value>
      </setting>
      <setting name="SMTP_auth_password" serializeAs="String">
        <value>yourmailserverpassword</value>
      </setting>
      <setting name="notify_email_to" serializeAs="String">
        <value>you@yourmailserver.com</value>
      </setting>
      <setting name="notify_email_from" serializeAs="String">
        <value>you@yourmailserver.com</value>
      </setting>
      <setting name="debug_level" serializeAs="String">
        <value>2</value>
      </setting>
    </BackupShutdownService.Properties.Settings>
  </applicationSettings>
</configuration>


System Requirements

  • Microsoft Windows 2000, XP, Vista, 2003
  • Microsoft .net Framework 2.0 or later (freely available here)

Download

Download MV Backup Server Safe Shutdown v0.1 (2008/09/22)
[downloaded 266 times]




Note: In order to the system can be successful shutdown, it is necessary that the LOCAL SERVICE user, that is the default user under MV Backup Server Safe Shutdown Service runs, has the ‘Shut down the system’ privilege. To assign this privilege, do Start > Administrative Tools > Local Security Policy > User Rights Assignment , then edit the "Shut down the system" entry adding the LOCAL SERVICE user.

I would love to hear from anyone who has any success with these instructions. Let me know if there is anything I missed.

Please consider supporting this project with a donation if it has been helpful to you.
Warning. The content of this article, and related downloads, is provided as-is; use at your own risk; no warranty; no promises; enjoy!
For more informations, please consult my disclaimer page.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Technorati
  • Sphinn
  • Facebook
  • LinkedIn
  • Live
Improve Microon Lounge rating this post
Tell me what do you think about "MV Backup Server Safe Shutdown Utility": I'll write better and better entries.
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4.00 out of 5)
Loading ... Loading ...

Leave a Reply


your name
your e-mail address
your website/url

Isn't this worth at least €1?

Any donation is appreciated, consider a €1 donation for each download (or maybe €1.35 since PayPal takes €0.35 from a €1.00 donation). Your support allows me to continue to create free software.