Changeset 1805
- Timestamp:
- 01/09/2007 21:57:13 (16 months ago)
- Location:
- box/chris/general/bin/bbackupd
- Files:
-
- 4 modified
-
BackupClientDirectoryRecord.cpp (modified) (1 diff)
-
BackupDaemon.cpp (modified) (8 diffs)
-
BackupDaemon.h (modified) (1 diff)
-
bbackupd-config.in (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/chris/general/bin/bbackupd/BackupClientDirectoryRecord.cpp
r1781 r1805 888 888 // Connection errors should just be passed on to the main handler, retries 889 889 // would probably just cause more problems. 890 // Already logged by UploadFile 890 rParams.GetProgressNotifier() 891 .NotifyFileUploadException( 892 this, filename, e); 891 893 throw; 892 894 } -
box/chris/general/bin/bbackupd/BackupDaemon.cpp
r1746 r1805 904 904 DeleteUnusedRootDirEntries(clientContext); 905 905 906 // Notify administrator 907 NotifySysadmin(NotifyEvent_BackupStart); 908 906 909 // Go through the records, syncing them 907 910 for(std::vector<Location *>::const_iterator … … 986 989 // Log 987 990 BOX_NOTICE("Finished scan of local files"); 991 992 // Notify administrator 993 NotifySysadmin(NotifyEvent_BackupFinish); 988 994 989 995 // -------------------------------------------------------------------------------------------- … … 2216 2222 // Function 2217 2223 // Name: BackupDaemon::NotifySysadmin(int) 2218 // Purpose: Run the script to tell the sysadmin about events which need attention. 2224 // Purpose: Run the script to tell the sysadmin about events 2225 // which need attention. 2219 2226 // Created: 25/2/04 2220 2227 // … … 2227 2234 "read-error", 2228 2235 "backup-error", 2236 "backup-start", 2237 "backup-finish", 2229 2238 0 2230 2239 }; 2231 2240 2241 BOX_TRACE("sizeof(sEventNames) == " << sizeof(sEventNames)); 2242 BOX_TRACE("sizeof(*sEventNames) == " << sizeof(*sEventNames)); 2243 BOX_TRACE("NotifyEvent__MAX == " << NotifyEvent__MAX); 2244 ASSERT((sizeof(sEventNames)/sizeof(*sEventNames)) == NotifyEvent__MAX + 1); 2245 2232 2246 BOX_TRACE("BackupDaemon::NotifySysadmin() called, event = " << 2233 2247 sEventNames[Event]); … … 2235 2249 if(Event < 0 || Event >= NotifyEvent__MAX) 2236 2250 { 2237 THROW_EXCEPTION(BackupStoreException, BadNotifySysadminEventCode); 2251 THROW_EXCEPTION(BackupStoreException, 2252 BadNotifySysadminEventCode); 2238 2253 } 2239 2254 2240 2255 // Don't send lots of repeated messages 2241 if(mNotificationsSent[Event]) 2242 { 2256 if(mNotificationsSent[Event] && 2257 Event != NotifyEvent_BackupStart && 2258 Event != NotifyEvent_BackupFinish) 2259 { 2260 BOX_WARNING("Suppressing duplicate notification about " << 2261 sEventNames[Event]); 2243 2262 return; 2244 2263 } … … 2246 2265 // Is there a notifation script? 2247 2266 const Configuration &conf(GetConfiguration()); 2248 if(!conf.KeyExists("NotifyScript")) 2267 if(!conf.KeyExists("NotifyScript") && 2268 Event != NotifyEvent_BackupStart && 2269 Event != NotifyEvent_BackupFinish) 2249 2270 { 2250 2271 // Log, and then return … … 2256 2277 2257 2278 // Script to run 2258 std::string script(conf.GetKeyValue("NotifyScript") + ' ' + sEventNames[Event]); 2279 std::string script(conf.GetKeyValue("NotifyScript") + ' ' + 2280 sEventNames[Event]); 2259 2281 2260 2282 // Log what we're about to do … … 2270 2292 } 2271 2293 2272 // Flag that this is done so the administrator isn't constantly bombarded with lots of errors 2294 // Flag that this is done so the administrator isn't constantly 2295 // bombarded with lots of errors 2273 2296 mNotificationsSent[Event] = true; 2274 2297 } -
box/chris/general/bin/bbackupd/BackupDaemon.h
r1781 r1805 86 86 NotifyEvent_ReadError, 87 87 NotifyEvent_BackupError, 88 NotifyEvent_BackupStart, 89 NotifyEvent_BackupFinish, 88 90 NotifyEvent__MAX 89 91 // When adding notifications, remember to add strings to NotifySysadmin() -
box/chris/general/bin/bbackupd/bbackupd-config.in
r1800 r1805 212 212 #!/bin/sh 213 213 214 # This script is run whenever bbackupd changes state or encounters a 215 # problem which requires the system administrator to assist: 216 # 217 # 1) The store is full, and no more data can be uploaded. 218 # 2) Some files or directories were not readable. 219 # 3) A backup run starts or finishes. 220 # 221 # The default script emails the system administrator, except for backups 222 # starting and stopping, where it does nothing. 223 214 224 SUBJECT="BACKUP PROBLEM on host $hostname" 215 225 SENDTO="$current_username" 216 226 217 if [ \$1 = store-full ] 218 then 219 $sendmail \$SENDTO <<EOM 227 if [ "\$1" = "" ]; then 228 echo "Usage: $0 <store-full|read-error|backup-error|backup-start|backup-finish>" >&2 229 exit 2 230 elif [ "\$1" = store-full ]; then 231 $sendmail \$SENDTO <<EOM 220 232 Subject: \$SUBJECT (store full) 221 233 To: \$SENDTO … … 231 243 232 244 EOM 233 elif [ \$1 = read-error ] 234 then 245 elif [ "\$1" = read-error ]; then 235 246 $sendmail \$SENDTO <<EOM 236 247 Subject: \$SUBJECT (read errors) … … 245 256 246 257 Check the logs on $hostname for the files and directories which caused 247 these errors, and take appropr aite action.258 these errors, and take appropriate action. 248 259 249 260 Other files are being backed up. 250 261 251 262 EOM 263 elif [ "\$1" = backup-start -o "\$1" = backup-finish ]; then 264 # do nothing by default 265 true 252 266 else 253 267 $sendmail \$SENDTO <<EOM … … 288 302 289 303 290 # This script is run whenever bbackupd encounters a problem which requires 291 # the system administrator to assist: 304 # This script is run whenever bbackupd changes state or encounters a 305 # problem which requires the system administrator to assist: 306 # 292 307 # 1) The store is full, and no more data can be uploaded. 293 308 # 2) Some files or directories were not readable. 294 # The default script emails the system administrator. 309 # 3) A backup run starts or finishes. 310 # 311 # The default script emails the system administrator, except for backups 312 # starting and stopping, where it does nothing. 295 313 296 314 NotifyScript = $notify_script … … 303 321 print CONFIG <<__E; 304 322 305 # The number of seconds between backup runs under normal conditions. A scan To306 # avoid cycles of load on the server, this time is randomly adjusted by a307 # smallpercentage as the daemon runs.323 # The number of seconds between backup runs under normal conditions. To avoid 324 # cycles of load on the server, this time is randomly adjusted by a small 325 # percentage as the daemon runs. 308 326 309 327 UpdateStoreInterval = 3600
