LCOV - code coverage report
Current view: top level - src/client - backup.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 0 21 0.0 %
Date: 2022-08-30 22:36:43 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #include "../burp.h"
       2             : #include "../action.h"
       3             : #include "../asfd.h"
       4             : #include "../async.h"
       5             : #include "../cntr.h"
       6             : #include "../conf.h"
       7             : #include "../handy.h"
       8             : #include "../log.h"
       9             : #include "backup_phase1.h"
      10             : #include "cvss.h"
      11             : #include "backup_phase2.h"
      12             : #include "backup.h"
      13             : 
      14             : #ifdef HAVE_WIN32
      15             : static void set_priority(int priority, const char *str)
      16             : {
      17             :         if(SetThreadPriority(GetCurrentThread(), priority))
      18             :                 logp("Set %s\n", str);
      19             :         else
      20             :                 logp("Failed to set %s\n", str);
      21             : }
      22             : 
      23             : static void set_low_priority(void)
      24             : {
      25             :         // Run timed backups with lower priority. I found that this has to be
      26             :         // done after the snapshot, or the snapshot never finishes. At least, I
      27             :         // waited 30 minutes with nothing happening.
      28             : #if defined(B_VSS_XP) || defined(B_VSS_W2K3)
      29             :         set_priority(THREAD_PRIORITY_LOWEST,
      30             :                 "thread_priority_lowest");
      31             : #else
      32             :         set_priority(THREAD_MODE_BACKGROUND_BEGIN,
      33             :                 "thread_mode_background_begin");
      34             : #endif
      35             : }
      36             : 
      37             : static void unset_low_priority(void)
      38             : {
      39             :         set_priority(THREAD_MODE_BACKGROUND_END,
      40             :                 "thread_mode_background_end");
      41             : }
      42             : #endif
      43             : 
      44             : // Return 0 for OK, -1 for error.
      45           0 : int do_backup_client(struct asfd *asfd, struct conf **confs, enum action action,
      46             :         int resume)
      47             : {
      48           0 :         int ret=-1;
      49           0 :         int breaking=get_int(confs[OPT_BREAKPOINT]);
      50             : 
      51           0 :         if(action==ACTION_ESTIMATE)
      52           0 :                 logp("do estimate client\n");
      53             :         else
      54             :         {
      55           0 :                 logp("do backup client\n");
      56           0 :                 logp("Using librsync hash %s\n",
      57             :                         rshash_to_str(get_e_rshash(confs[OPT_RSHASH])));
      58             :         }
      59             : 
      60             : #ifdef HAVE_WIN32
      61             :         win32_enable_backup_privileges();
      62             : #ifdef WIN32_VSS
      63             :         if(win32_start_vss(asfd, confs))
      64             :         {
      65             :                 log_and_send(asfd, "Problem with VSS\n");
      66             :                 return ret;
      67             :         }
      68             : #endif
      69             :         if(action==ACTION_BACKUP_TIMED) set_low_priority();
      70             : #endif
      71             : 
      72             :         // Scan the file system and send the results to the server.
      73             :         // Skip phase1 if the server wanted to resume.
      74           0 :         if(!resume)
      75             :         {
      76           0 :                 if(breaking==1)
      77             :                 {
      78           0 :                         breakpoint(breaking, __func__);
      79           0 :                         goto end;
      80             :                 }
      81           0 :                 if(backup_phase1_client(asfd, confs))
      82             :                         goto end;
      83             :         }
      84             : 
      85           0 :         switch(action)
      86             :         {
      87             :                 case ACTION_DIFF:
      88             :                 case ACTION_DIFF_LONG:
      89             :                         ret=1;
      90             :                         goto end;
      91             :                 case ACTION_ESTIMATE:
      92           0 :                         cntr_print(get_cntr(confs), ACTION_ESTIMATE);
      93           0 :                         break;
      94             :                 default:
      95             :                         // Now, the server will be telling us what data we need
      96             :                         // to send.
      97           0 :                         if(breaking==2)
      98             :                         {
      99           0 :                                 breakpoint(breaking, __func__);
     100           0 :                                 goto end;
     101             :                         }
     102             : 
     103           0 :                         ret=backup_phase2_client(asfd,
     104             :                                 confs, resume);
     105           0 :                         if(ret) goto end;
     106             :                         break;
     107             :         }
     108             : 
     109             :         ret=0;
     110             : end:
     111             : #if defined(HAVE_WIN32)
     112             :         if(action==ACTION_BACKUP_TIMED) unset_low_priority();
     113             : #if defined(WIN32_VSS)
     114             :         win32_stop_vss();
     115             : #endif
     116             : #endif
     117           0 :         return ret;
     118             : }

Generated by: LCOV version 1.13