def main(): lg.set_debug_level(24) backupID = sys.argv[1] raid_worker.A('init') outfd, outfilename = tmpfile.make('restore', '.tar.gz', backupID.replace('/', '_') + '_') r = restore(backupID, outfd) r.MyDeferred.addBoth(lambda x: reactor.stop()) reactor.callLater(1, r.automat, 'init') reactor.run()
def main(): from system import bpio from . import backup_tar from . import backup_fs lg.set_debug_level(24) sourcePath = sys.argv[1] compress_mode = 'none' # 'gz' backupID = sys.argv[2] raid_worker.A('init') backupPath = backup_fs.MakeLocalDir(settings.getLocalBackupsDir(), backupID) if bpio.pathIsDir(sourcePath): backupPipe = backup_tar.backuptardir(sourcePath, compress=compress_mode) else: backupPipe = backup_tar.backuptarfile(sourcePath, compress=compress_mode) backupPipe.make_nonblocking() def _bk_done(bid, result): from crypt import signed customer, remotePath = packetid.SplitPacketID(bid) try: os.mkdir( os.path.join(settings.getLocalBackupsDir(), customer, remotePath + '.out')) except: pass for filename in os.listdir( os.path.join(settings.getLocalBackupsDir(), customer, remotePath)): filepath = os.path.join(settings.getLocalBackupsDir(), customer, remotePath, filename) payld = bpio.ReadBinaryFile(filepath) newpacket = signed.Packet('Data', my_id.getLocalID(), my_id.getLocalID(), filename, payld, 'http://megafaq.ru/cvps1010.xml') newfilepath = os.path.join(settings.getLocalBackupsDir(), customer, remotePath + '.out', filename) bpio.WriteBinaryFile(newfilepath, newpacket.Serialize()) reactor.stop() # @UndefinedVariable job = backup(backupID, backupPipe, _bk_done) reactor.callLater(1, job.automat, 'start') # @UndefinedVariable reactor.run() # @UndefinedVariable
def main(): sourcePath = sys.argv[1] backupID = sys.argv[2] lg.set_debug_level(24) compress_mode = 'none' # 'gz' raid_worker.A('init') backupPath = backup_fs.MakeLocalDir(settings.getLocalBackupsDir(), backupID) if bpio.pathIsDir(sourcePath): backupPipe = backup_tar.backuptardir(sourcePath, compress=compress_mode) else: backupPipe = backup_tar.backuptarfile(sourcePath, compress=compress_mode) backupPipe.make_nonblocking() job = backup.backup(backupID, backupPipe, backup_done) reactor.callLater(1, job.automat, 'start') reactor.run()
def stop(self): from raid import raid_worker from storage import backup_rebuilder backup_rebuilder.Destroy() raid_worker.A('shutdown') return True
def start(self): from raid import raid_worker from storage import backup_rebuilder raid_worker.A('init') backup_rebuilder.A('init') return True
def doKillRebuilders(self, arg): """ Action method. """ raid_worker.A('shutdown')
def doKillRebuilders(self, *args, **kwargs): """ Action method. """ # TODO: make sure to not kill workers for backup jobs.... raid_worker.A('shutdown')
def main(): from system import bpio from storage import backup_tar bpio.init() settings.init() lg.set_debug_level(24) lg.life_begins() automat.LifeBegins(lg.when_life_begins()) automat.OpenLogFile(settings.AutomatsLog()) key.InitMyKey() my_id.init() sourcePath = sys.argv[1] compress_mode = 'none' # 'gz' backupID = sys.argv[2] raid_worker.A('init') if bpio.pathIsDir(sourcePath): backupPipe = backup_tar.backuptardir_thread(sourcePath, compress=compress_mode) else: backupPipe = backup_tar.backuptarfile_thread(sourcePath, compress=compress_mode) def _bk_done(bid, result): from crypt import signed customer, remotePath = packetid.SplitPacketID(bid) try: os.mkdir( os.path.join(settings.getLocalBackupsDir(), customer, remotePath + '.out')) except: pass for filename in os.listdir( os.path.join(settings.getLocalBackupsDir(), customer, remotePath)): filepath = os.path.join(settings.getLocalBackupsDir(), customer, remotePath, filename) payld = bpio.ReadBinaryFile(filepath) newpacket = signed.Packet('Data', my_id.getLocalID(), my_id.getLocalID(), filename, payld, 'http://megafaq.ru/cvps1010.xml') newfilepath = os.path.join(settings.getLocalBackupsDir(), customer, remotePath + '.out', filename) bpio.WriteBinaryFile(newfilepath, newpacket.Serialize()) def _bk_closed(*args, **kwargs): # job.automat('fail') # del job reactor.stop() # @UndefinedVariable def _bk_start(): job = backup(backupID, backupPipe, blockSize=16 * 1024 * 1024) job.finishCallback = _bk_done # lambda bid, result: _bk_done(bid, result, job) job.addStateChangedCallback(_bk_closed, oldstate=None, newstate='DONE') reactor.callLater(1, job.automat, 'start') # @UndefinedVariable reactor.callLater(0, _bk_start) # @UndefinedVariable reactor.run() # @UndefinedVariable settings.shutdown()