from ftplib import FTP
import time,os,sys
print "按回车开始备份"
raw_input()
ftp=FTP()
ftp.set_debuglevel(2)
ftp.connect('服务器IP', '21')
ftp.login("用户名","密码")
ftp.cwd('/wwwroot/bbs/DataBase')
now = time.localtime()
blocksize = 1024
poststr = str(now.tm_year)+"-"+str(now.tm_mon)+"-"+str(now.tm_mday)
filename=r'e:\网站备份\bbs\database\Dbbs7'+poststr+'.asp'
if(os.path.isfile(filename)):
print "文件已经存在"
raw_input()
sys.exit()
file_handler = open(filename,'w').write
ftp.retrbinary("RETR Dbbs7.asp", file_handler, blocksize)
ftp.quit()
print "下载完毕"
raw_input()