#-*- coding: utf-8 -*-#!/usr/bin/python
'''Created on 2018年7月6日
@author: yanghang
Description:'''
importtarfileimportdatetimeimportosimportftplibimportpymysql#上传至ftp
defupload_file(ftpHost, ftpUser, ftpPwd, ftpDir, fileName, overdueFileName):
ftp=ftplib.FTP(ftpHost)
ftp.login(ftpUser, ftpPwd)try:
ftp.mkd(ftpDir)exceptException as e:print(e)
ftp.cwd(ftpDir)try:
ftp.delete(overdueFileName)exceptException as e:print(e)
ftp.storbinary("STOR" + fileName, open(fileName, "rb"))
ftp.quit()#tar打包
deftar_file(backup_path, package_name, local_path):
os.chdir(backup_path)
tar= tarfile.open(package_name, 'w:gz', encoding='UTF-8')
tar.add(local_path)
tar.close()#获取数据库所包含的库列表
defget_dbname_list(host,user,passwd,dbname,sql):""