示例#1
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError('Must provide a zipfile path')
        backup_path = os.path.normpath(os.path.expanduser(args[0]))
        if not os.path.exists(backup_path):
            raise CommandError('Archive does not exist: {}'.format(backup_path))

        try:
            backup.restore(backup_path)
        except backup.BackupError as e:
            sys.stderr.write('Error: ')
            sys.stderr.write(e.message)
            sys.stderr.write('\n')
            sys.exit(1)
示例#2
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError('Must provide a zipfile path')
        backup_path = os.path.normpath(os.path.expanduser(args[0]))
        if not os.path.exists(backup_path):
            raise CommandError(
                'Archive does not exist: {}'.format(backup_path))

        try:
            backup.restore(backup_path)
        except backup.BackupError as e:
            sys.stderr.write('Error: ')
            sys.stderr.write(e.message)
            sys.stderr.write('\n')
            sys.exit(1)
示例#3
0
    def handle(self, *args, **options):
        if not options['site']:
            raise CommandError('Must give --site')

        if not (bool(options['dump']) ^ bool(options['restore'])):
            raise CommandError('Must give exactly one of: --dump=<filename>, --restore=<filename>')

        kbsite = self.prep_site(options['site'], options['restore'])

        if options['restore']:
            input_fp = open(options['restore'], 'r')
            backup.restore(input_fp, kbsite, self.debug)
            input_fp.close()
        else:
            indent = None
            if options['indent']:
                indent = 2
            output_fp = open(options['dump'], 'w')
            backup.dump(output_fp, kbsite, indent, self.debug)
            output_fp.close()
示例#4
0
  def handle(self, **options):
    if not options['site']:
      raise CommandError('Must give --site')

    if not (bool(options['dump']) ^ bool(options['restore'])):
      raise CommandError('Must give exactly one of: --dump=<filename>, --restore=<filename>')

    try:
      kbsite = models.KegbotSite.objects.get(name=options['site'])
    except models.KegbotSite.DoesNotExist:
      raise CommandError('Site does not exist')

    if options['restore']:
      input_fp = open(options['restore'], 'r')
      backup.restore(input_fp, kbsite, self.debug)
      input_fp.close()
    else:
      indent = None
      if options['indent']:
        indent = 2
      output_fp = open(options['dump'], 'w')
      backup.dump(output_fp, kbsite, indent, self.debug)
      output_fp.close()