""" Author: Tyler Laing Date: Aug 29, 06 Backup script of all neccesary files. This gets placed in the lib directory. Then just run it, via a cron job or manually if you wish. It recursively copies all folders and files, but does the previous backup will be lost. """ import os, shutil from os.path import join, exists, isdir BACKUPDIR='../backup' def start(top='.'): names = os.listdir(top) dirs, nondirs = [], [] for name in names: if isdir(join(top, name)): dirs.append(name) else: nondirs.append(name) if not exists(join(BACKUPDIR, top)): os.mkdir(join(BACKUPDIR, top)) for file in nondirs: shutil.copyfile(join(top, file), join(join(BACKUPDIR, top),file)) shutil.copymode(join(top, file), join(join(BACKUPDIR, top),file)) shutil.copystat(join(top, file), join(join(BACKUPDIR, top),file)) for Dir in dirs: start(join(top, Dir)) start()