예제 #1
0
 def querysql(self,tablename):
     db = backupserver.filemsg()
     querysql = "select * from %s" % tablename +" where ip = '%s'" % ipaddress
     print querysql
     sqlmsg = db.readfilemsf('DB').query(querysql)
     for i in range(0,len(sqlmsg)):
         print sqlmsg[i]
예제 #2
0
    def ftpqueryandresv(self,queryip):
        self.connectftp(queryip)
        listbackname=self.ftpclient.nlst()


        db = backupserver.filemsg()
        getupdatesql = "select backupfilename from backup_info where now_status ='N/A' or now_status='alive'"
        date = db.readfilemsf('DB').query(getupdatesql)

        for i in range(0,len(date)):                                    #更新数据库,判断备份数据包是否存在
            tag = '0'
            for j in range(0,len(listbackname)):
                if (date[i][0] == listbackname[j]):
                    updatesql = "update backup_info set now_status='alive' where backupfilename='%s'"%date[i][0]
                    db.readfilemsf('DB').connect(updatesql)
                    tag = '1'
                    break
            if tag == '0':
                updatesqldel = "update backup_info set now_status='del' where backupfilename='%s'"%date[i][0]
                db.readfilemsf('DB').connect(updatesqldel)

        getbackzipfile=self.choiceserver(listbackname)

        if(getbackzipfile==None):
            print "please backup first  !!!"
        print "getbackzipfile",getbackzipfile
        getupdatename = str(self.queryresvdir(getbackzipfile)[0][0]).split()

        getbackname=self.choiceserver(getupdatename)

        print "getzip",getbackzipfile

        print getbackname+'.tar.gz'
        self.remrecbakcomn(queryip,'resv '+getbackzipfile+' '+getbackname+'.tar.gz')
        self.ftpclient.quit()
예제 #3
0
 def queryresvdir(self,resvname):
     db = backupserver.filemsg()
     querysql = "select dirs from backup_info where backupfilename='%s'" % resvname
     return db.readfilemsf('DB').query(querysql)