Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- This script creates a daily backup
- of ICS files on an FTP server.
- The backups are stored local and on backups-dir on
- ftp server :)
- """
- from ftplib import FTP
- from datetime import date
- class FTPMan():
- def __init__(self, bla):
- self.ftp = FTP(bla)
- def login(self, user, pwd):
- self.ftp.login(user, pwd)
- def CWD(self, dir):
- self.ftp.cwd(dir)
- def download(self, file, targetFile):
- self.ftp.retrbinary('RETR ' + file, open(targetFile,"wb").write)
- def upload(self, targetFile, localfile):
- self.ftp.storbinary('STOR ' + targetFile, localfile)
- def dc(self):
- self.ftp.quit()
- def main():
- backupname = 'allgemein-' + str(date.today().day) + '-' + str(date.today().month) + '-' + str(date.today().year) + '.ics'
- man = FTPMan('ftp-serveradress.com')
- man.login('username','password')
- man.CWD('Kalender')
- man.download('allgemein.ics',backupname)
- man.CWD('backups')
- f = open(backupname,"rb")
- man.upload(backupname, f)
- man.dc()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement