예제 #1
0
파일: defer.py 프로젝트: recursix/pyjobber
 def backup(self):
     # Writing backup in two steps. 
     # This tries to avoid being killed while overwriting an existing backup
     
     print 'writing bkp %s'%self.bkpPath
     fileUtil.writePklz(self.dObj, self.bkpPathTmp)
     
     if self.incrBkp:
         p,ext = path.splitext(self.bkpPath)
         bkpPath = p + str(self.incr) + ext
         self.incr +=1
     else:
         bkpPath = self.bkpPath
         
     os.rename(self.bkpPathTmp, bkpPath) 
     self.lastBackup = time.time()
예제 #2
0
파일: bkp.py 프로젝트: recursix/pyjobber
    def backup(self):
        # Writing backup in two steps. This avoids the case where
        # the processes is being killed while the bkp is partly overwritten.
        
#        print 'writing bkp %s'%self.bkpPath
        try:
            if hasattr(self.obj, "extract"):
                bkp_dict = self.obj.extract()
            else:
                bkp_dict = {'out': self.obj}
            
            for name, obj in bkp_dict.items():
                tmp_bkp_path = path.join(self.bkp_folder, '%s-tmp.pklz'%name )
                bkp_path = path.join(self.bkp_folder, '%s.pklz'%name )
                file.writePklz( obj, tmp_bkp_path )            
                os.rename(tmp_bkp_path, bkp_path) 
                
            self.lastBackup = t.time()
        except RuntimeError:
            if self.done: raise
            else:
                print('Error occurred during backup. Will try again...')