| 278 | | "==============================================================================\n" |
| 279 | | "SECURITY WARNING: This platform cannot check the credentials of connections to\n" |
| 280 | | "the command socket. This is a potential DoS security problem.\n" |
| 281 | | "Remove the CommandSocket directive from the bbackupd.conf file if bbackupctl\n" |
| 282 | | "is not used.\n" |
| 283 | | "==============================================================================\n" |
| | 278 | "==============================================================================\n" |
| | 279 | "SECURITY WARNING: This platform cannot check the credentials of connections to\n" |
| | 280 | "the command socket. This is a potential DoS security problem.\n" |
| | 281 | "Remove the CommandSocket directive from the bbackupd.conf file if bbackupctl\n" |
| | 282 | "is not used.\n" |
| | 283 | "==============================================================================\n" |
| 869 | | // Touch a file to record times in filesystem |
| 870 | | TouchFileInWorkingDir("last_sync_start"); |
| 871 | | |
| 872 | | // Tell anything connected to the command socket |
| 873 | | SendSyncStartOrFinish(true /* start */); |
| 874 | | |
| 875 | | // Reset statistics on uploads |
| 876 | | BackupStoreFile::ResetStats(); |
| 877 | | |
| 878 | | // Delete the serialised store object file, |
| 879 | | // so that we don't try to reload it after a |
| 880 | | // partially completed backup |
| 881 | | if(mDeleteStoreObjectInfoFile && |
| 882 | | !DeleteStoreObjectInfo()) |
| 883 | | { |
| 884 | | BOX_ERROR("Failed to delete the " |
| 885 | | "StoreObjectInfoFile, backup cannot " |
| 886 | | "continue safely."); |
| 887 | | THROW_EXCEPTION(ClientException, |
| 888 | | FailedToDeleteStoreObjectInfoFile); |
| 889 | | } |
| 890 | | |
| 891 | | // In case the backup throws an exception, |
| 892 | | // we should not try to delete the store info |
| 893 | | // object file again. |
| 894 | | mDeleteStoreObjectInfoFile = false; |
| 895 | | |
| 907 | | |
| 908 | | // Errors reading any files? |
| 909 | | if(mReadErrorsOnFilesystemObjects) |
| 910 | | { |
| 911 | | // Notify administrator |
| 912 | | NotifySysadmin(NotifyEvent_ReadError); |
| 913 | | } |
| 914 | | else |
| 915 | | { |
| 916 | | // Unset the read error flag, so the |
| 917 | | // error is reported again if it |
| 918 | | // happens again |
| 919 | | mNotificationsSent[NotifyEvent_ReadError] = false; |
| 920 | | } |
| 921 | | |
| 922 | | // Check the storage limit |
| 923 | | if(mStorageLimitExceeded) |
| 924 | | { |
| 925 | | // Tell the sysadmin about this |
| 926 | | NotifySysadmin(NotifyEvent_StoreFull); |
| 927 | | } |
| 928 | | else |
| 929 | | { |
| 930 | | // unflag the storage full notify flag |
| 931 | | // so that next time the store is full, |
| 932 | | // an alert will be sent |
| 933 | | mNotificationsSent[NotifyEvent_StoreFull] = false; |
| 934 | | } |
| 935 | | |
| 936 | | // Calculate when the next sync run should be |
| 937 | | mNextSyncTime = mCurrentSyncStartTime + |
| 938 | | mUpdateStoreInterval + |
| 939 | | Random::RandomInt(mUpdateStoreInterval >> |
| 940 | | SYNC_PERIOD_RANDOM_EXTRA_TIME_SHIFT_BY); |
| 941 | | |
| 942 | | // Notify administrator |
| 943 | | NotifySysadmin(NotifyEvent_BackupFinish); |
| 944 | | |
| 945 | | // -------------------------------------------------------------------------------------------- |
| 946 | | |
| 947 | | // We had a successful backup, save the store |
| 948 | | // info. If we save successfully, we must |
| 949 | | // delete the file next time we start a backup |
| 950 | | |
| 951 | | mDeleteStoreObjectInfoFile = |
| 952 | | SerializeStoreObjectInfo(mLastSyncTime, |
| 953 | | mNextSyncTime); |
| 954 | | |
| 955 | | // -------------------------------------------------------------------------------------------- |
| 956 | | |
| 957 | | // If we were retrying after an error, |
| 958 | | // now would be a good time to stop :-) |
| 959 | | mDoSyncForcedByPreviousSyncError = false; |
| | 988 | // Touch a file to record times in filesystem |
| | 989 | TouchFileInWorkingDir("last_sync_start"); |
| | 990 | |
| | 991 | // Tell anything connected to the command socket |
| | 992 | SendSyncStartOrFinish(true /* start */); |
| | 993 | |
| | 994 | // Reset statistics on uploads |
| | 995 | BackupStoreFile::ResetStats(); |
| | 996 | |
| | 997 | // Delete the serialised store object file, |
| | 998 | // so that we don't try to reload it after a |
| | 999 | // partially completed backup |
| | 1000 | if(mDeleteStoreObjectInfoFile && |
| | 1001 | !DeleteStoreObjectInfo()) |
| | 1002 | { |
| | 1003 | BOX_ERROR("Failed to delete the " |
| | 1004 | "StoreObjectInfoFile, backup cannot " |
| | 1005 | "continue safely."); |
| | 1006 | THROW_EXCEPTION(ClientException, |
| | 1007 | FailedToDeleteStoreObjectInfoFile); |
| | 1008 | } |
| | 1009 | |
| | 1010 | // In case the backup throws an exception, |
| | 1011 | // we should not try to delete the store info |
| | 1012 | // object file again. |
| | 1013 | mDeleteStoreObjectInfoFile = false; |
| | 1014 | |
| | 1015 | // Notify administrator |
| | 1016 | NotifySysadmin(NotifyEvent_BackupStart); |
| | 1017 | |
| | 1250 | |
| | 1251 | |
| | 1252 | // Errors reading any files? |
| | 1253 | if(mReadErrorsOnFilesystemObjects) |
| | 1254 | { |
| | 1255 | // Notify administrator |
| | 1256 | NotifySysadmin(NotifyEvent_ReadError); |
| | 1257 | } |
| | 1258 | else |
| | 1259 | { |
| | 1260 | // Unset the read error flag, so the |
| | 1261 | // error is reported again if it |
| | 1262 | // happens again |
| | 1263 | mNotificationsSent[NotifyEvent_ReadError] = false; |
| | 1264 | } |
| | 1265 | |
| | 1266 | // Check the storage limit |
| | 1267 | if(mStorageLimitExceeded) |
| | 1268 | { |
| | 1269 | // Tell the sysadmin about this |
| | 1270 | NotifySysadmin(NotifyEvent_StoreFull); |
| | 1271 | } |
| | 1272 | else |
| | 1273 | { |
| | 1274 | // unflag the storage full notify flag |
| | 1275 | // so that next time the store is full, |
| | 1276 | // an alert will be sent |
| | 1277 | mNotificationsSent[NotifyEvent_StoreFull] = false; |
| | 1278 | } |
| | 1279 | |
| | 1280 | // Calculate when the next sync run should be |
| | 1281 | mNextSyncTime = mCurrentSyncStartTime + |
| | 1282 | mUpdateStoreInterval + |
| | 1283 | Random::RandomInt(mUpdateStoreInterval >> |
| | 1284 | SYNC_PERIOD_RANDOM_EXTRA_TIME_SHIFT_BY); |
| | 1285 | |
| | 1286 | // Notify administrator |
| | 1287 | NotifySysadmin(NotifyEvent_BackupFinish); |
| | 1288 | |
| | 1289 | // -------------------------------------------------------------------------------------------- |
| | 1290 | |
| | 1291 | // We had a successful backup, save the store |
| | 1292 | // info. If we save successfully, we must |
| | 1293 | // delete the file next time we start a backup |
| | 1294 | |
| | 1295 | mDeleteStoreObjectInfoFile = |
| | 1296 | SerializeStoreObjectInfo(mLastSyncTime, |
| | 1297 | mNextSyncTime); |
| | 1298 | |
| | 1299 | // -------------------------------------------------------------------------------------------- |
| 1852 | | for(std::list<std::pair<std::string, Configuration> >::const_iterator i = rLocationsConf.mSubConfigurations.begin(); |
| 1853 | | i != rLocationsConf.mSubConfigurations.end(); ++i) |
| 1854 | | { |
| 1855 | | BOX_TRACE("new location: " << i->first); |
| | 1851 | std::vector<std::string> locNames = |
| | 1852 | rLocationsConf.GetSubConfigurationNames(); |
| | 1853 | |
| | 1854 | for(std::vector<std::string>::iterator |
| | 1855 | pLocName = locNames.begin(); |
| | 1856 | pLocName != locNames.end(); |
| | 1857 | pLocName++) |
| | 1858 | { |
| | 1859 | const Configuration& rConfig( |
| | 1860 | rLocationsConf.GetSubConfiguration(*pLocName)); |
| | 1861 | BOX_TRACE("new location: " << *pLocName); |
| | 1862 | |