FileTypes= [ "*.h", "*.c", "*.cpp", "*.asm", "*.inc", "*.dsp", "*.rc",
".wdr" ]
BackupDir= "Path to the root folder you want backed up"
DestDir= "Path on your local machine where you want to store the backups"
FTPUpload= "url of your ftp site"
FTPUsername= "your ftp login"
FTPPassword= "your ftp password"
FTPDir= "folder on the ftp site to store backups"
Pkzip= "Location of pkzipc.exe "
ZipPassword= "Password to encrypt the zip file"
import time
import os
ZipName= time.strftime( "work_(%d-%B-%Y)_(%H-%M).zip" )
ZipPath= DestDir + "/" + ZipName
os.chdir( BackupDir )
os.spawnv( os.P_WAIT, Pkzip, [ Pkzip ] + [ "-add", "-rec", "-path",
"-pass="+ZipPassword ] + [ ZipPath ] + FileTypes )
from ftplib import FTP
ftp= FTP( FTPUpload )
ftp.login( FTPUsername, FTPPassword )
ftp.cwd( FTPDir )
UploadFile= file( ZipPath, "rb" )
ftp.storbinary( "STOR " + ZipName, UploadFile )
ftp.quit()
UploadFile.close()
|