def task_restore(self, localfile, restoreDb=True): """ Restore all information not stored in version control from a tarball on the invoking users machine. """ restoreDb = str(restoreDb).lower() in ('true', '1', 'yes', 'ok', 'y') if restoreDb: msg = ( 'All existing files present in the backup will be overwritten and\n' 'the database dropped and recreated.' ) else: msg = ( 'All existing files present in the backup will be overwritten\n' '(the database will not be touched).' ) print '' if confirm(msg): # TODO: Ask for confirmation here if restoreDb: postgres.dropDb('trac') postgres.createDb('trac', 'trac') with settings(user=self.serviceUser): with utils.tempfile() as temp: archive.restore({ 'htpasswd': 'config/htpasswd', 'attachments': 'attachments', 'db.dump': temp, }, localfile) if restoreDb: postgres.restoreFromPath('trac', temp)
def task_restore(self, localfile, restoreDb=True, withAttachments=True): """ Restore all information not stored in version control from a tarball on the invoking users machine. """ restoreDb = str(restoreDb).lower() in ('true', '1', 'yes', 'ok', 'y') if restoreDb: msg = ( 'All existing files present in the backup will be overwritten and\n' 'the database dropped and recreated.') else: msg = ( 'All existing files present in the backup will be overwritten\n' '(the database will not be touched).') print('') if confirm(msg): # TODO: Ask for confirmation here if restoreDb: postgres.dropDb('trac') postgres.createDb('trac', 'trac') with settings(user=self.serviceUser): with utils.tempfile() as temp: files = { 'db.dump': temp, } if withAttachments is True: files['attachments'] = 'attachments' archive.restore(files, localfile) if restoreDb: postgres.restoreFromPath('trac', temp)
def task_restore(self, dump): """ Resotre non-versioned resources. """ msg = 'All non-versioned web resources will be replaced with the backup.' if confirm(msg): with settings(user=self.serviceUser): archive.restore({ 'data': 'data', }, dump)
def task_restore(self, dump): """ Restore mailman data. """ msg = 'All mailman state and archives will be replaced with the backup.' if confirm(msg): with settings(user=self.serviceUser): archive.restore({ 'lists': 'lists', 'data': 'data', 'archives': 'archives' }, dump)
def task_restore(self, localfile): """ Restore all information not stored in version control from a tarball on the invoking users machine. """ msg = 'The whole data directory will be replaced with the backup.' if confirm(msg): with settings(user=self.serviceUser): archive.restore({ 'data': 'data', }, localfile)
def task_restore(self, dump): """ Restore mailman data. """ msg = 'All mailman state and archives will be replaced with the backup.' if confirm(msg): with settings(user=self.serviceUser): archive.restore( { 'lists': 'lists', 'data': 'data', 'archives': 'archives' }, dump)
def task_restore(self, localfile): """ Restore codespeed database from the given C{localfile}. """ msg = 'The whole database will be replaced with the backup.' if utils.confirm(msg): with settings(user=self.serviceUser): with utils.tempfile() as temp: archive.restore({ 'db.dump': temp, }, localfile) run('/bin/rm -f ~/data/codespeed.db') run('/usr/bin/sqlite3 ~/data/codespeed.db ".read {}"'.format(temp))
def task_generateSecretKey(self): """ Generate a new C{SECRET_KEY} and save it in the settings file. """ with settings(user=self.serviceUser): if utils.succeeds('ls {}/secret_key.py'.format(self.configDir)): execute = utils.confirm('This will replace the current secret ' 'key with a newly generated one.') else: execute = True if execute: chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' secret = ''.join([random.choice(chars) for i in range(50)]) setting = StringIO("SECRET_KEY = '{}'\n".format(secret)) put(setting, '{}/secret_key.py'.format(self.configDir), mode=0o600)