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_install(self): """ Install trac. """ self.bootstrap(python='system') with settings(user=self.serviceUser): pip.install('psycopg2', python='system') self.update(_installDeps=True) run('/bin/mkdir -p ~/svn') run('/bin/ln -nsf ~/svn {}/trac-env/svn-repo'.format(self.configDir)) run('/bin/mkdir -p ~/attachments') run('/bin/ln -nsf ~/attachments {}/trac-env/files/attachments'.format( self.configDir)) run('/bin/ln -nsf {} {}/trac-env/log'.format(self.logDir, self.configDir)) run('/bin/ln -nsf {}/start {}/start'.format(self.configDir, self.binDir)) cron.install(self.serviceUser, '{}/crontab'.format(self.configDir)) # Create an empty password file if not present. run('/usr/bin/touch config/htpasswd') # FIXME: Make these idempotent. postgres.createUser('trac') postgres.createDb('trac', 'trac')
def task_install(self): """ Install trac. """ self.bootstrap(python='system') # FIXME: Make these idempotent. postgres.createUser('trac') postgres.createDb('trac', 'trac') with settings(user=self.serviceUser): pip.install('psycopg2 pygments', python='system') self.update(_installDeps=True) # Note that this has to be after trac is installed, to get the right version pip.install('TracAccountManager==0.4.3', python='system') run('/bin/mkdir -p ~/svn') run('/bin/ln -nsf ~/svn {}/trac-env/svn-repo'.format(self.configDir)) run('/bin/mkdir -p ~/attachments') run('/bin/ln -nsf ~/attachments {}/trac-env/files/attachments'.format( self.configDir)) run('/bin/ln -nsf ~/website/trac-files {}/trac-env/htdocs'.format( self.configDir)) run('/bin/ln -nsf {} {}/trac-env/log'.format(self.logDir, self.configDir)) run('/bin/ln -nsf {}/start {}/start'.format(self.configDir, self.binDir)) cron.install(self.serviceUser, '{}/crontab'.format(self.configDir))
def task_install(self): """ Install trac. """ self.bootstrap() with settings(user=self.serviceUser): self.update() run('/bin/mkdir -p ~/attachments') run('/bin/ln -nsf ~/attachments {}/trac-env/files/attachments'. format(self.configDir)) run('/bin/ln -nsf {} {}/trac-env/log'.format( self.logDir, self.configDir)) run('/bin/ln -nsf {}/start {}/start'.format( self.configDir, self.binDir)) cron.install(self.serviceUser, '{}/crontab'.format(self.configDir)) # FIXME: Make these idempotent. postgres.createUser('trac') postgres.createDb('trac', 'trac')
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_install(self): """ Install trac. """ self.bootstrap() with settings(user=self.serviceUser): self.update() run('/bin/mkdir -p ~/attachments') run('/bin/ln -nsf ~/attachments {}/trac-env/files/attachments'.format( self.configDir)) run('/bin/ln -nsf {} {}/trac-env/log'.format(self.logDir, self.configDir)) run('/bin/ln -nsf {}/start {}/start'.format(self.configDir, self.binDir)) cron.install(self.serviceUser, '{}/crontab'.format(self.configDir)) # FIXME: Make these idempotent. postgres.createUser('trac') postgres.createDb('trac', 'trac') # We don't have a braid rule for highscore, # so I am just hacking this here to have a functional restore. postgres.createUser('highscore') postgres.grantRead('trac', 'highscore') # amptrack has a dedicated braid, but is better to have it here # so that dump and restore don't depend on it. postgres.createUser('amptrac') postgres.grantRead('trac', 'amptrac')
def task_install(self): """ Install trac. """ self.bootstrap(python='system') # FIXME: Make these idempotent. postgres.createUser('trac') postgres.createDb('trac', 'trac') with settings(user=self.serviceUser): pip.install('psycopg2 pygments', python='system') self.update(_installDeps=True) # Note that this has to be after trac is installed, to get the right version pip.install('TracAccountManager==0.4.3', python='system') run('/bin/mkdir -p ~/svn') run('/bin/ln -nsf ~/svn {}/trac-env/svn-repo'.format(self.configDir)) run('/bin/mkdir -p ~/attachments') run('/bin/ln -nsf ~/attachments {}/trac-env/attachments'.format( self.configDir)) run('/bin/ln -nsf ~/website/trac-files {}/trac-env/htdocs'.format( self.configDir)) run('/bin/ln -nsf {} {}/trac-env/log'.format(self.logDir, self.configDir)) run('/bin/ln -nsf {}/start {}/start'.format(self.configDir, self.binDir)) cron.install(self.serviceUser, '{}/crontab'.format(self.configDir))
def task_install(self): """ Install trac. """ self.bootstrap() with settings(user=self.serviceUser): self.update() run('/bin/mkdir -p ~/attachments') run('/bin/ln -nsf ~/attachments {}/trac-env/files/attachments'.format( self.configDir)) run('/bin/ln -nsf {} {}/trac-env/log'.format(self.logDir, self.configDir)) run('/bin/ln -nsf {}/start {}/start'.format(self.configDir, self.binDir)) cron.install(self.serviceUser, '{}/crontab'.format(self.configDir)) # FIXME: Make these idempotent. postgres.createUser('trac') postgres.createDb('trac', 'trac')