Exemple #1
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(description='Clone an S3QL file system.')

    parser.add_authfile()
    parser.add_quiet()
    parser.add_debug()
    parser.add_backend_options()
    parser.add_version()

    parser.add_argument(
        "src_storage_url",
        metavar='<source-storage-url>',
        type=storage_url_type,
        help='Storage URL of the source backend that contains the file system')

    parser.add_argument("dst_storage_url",
                        metavar='<destination-storage-url>',
                        type=storage_url_type,
                        help='Storage URL of the destination backend')

    parser.add_argument("--threads",
                        type=int,
                        default=3,
                        help='Number of threads to use')

    return parser.parse_args(args)
Exemple #2
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description='Recursively copy source(s) to destination using multiple '
        'parallel rsync processes.')

    parser.add_quiet()
    parser.add_debug()
    parser.add_version()

    parser.add_argument("-a",
                        action="store_true",
                        help='Pass -aHAX option to rsync.')
    parser.add_argument(
        "--processes",
        action="store",
        type=int,
        metavar='<no>',
        default=10,
        help='Number of rsync processes to use (default: %(default)s).')

    parser.add_argument('source',
                        metavar='<source>',
                        nargs='+',
                        help='Directories to copy')
    parser.add_argument('dest',
                        metavar='<destination>',
                        help="Target directory")

    options = parser.parse_args(args)
    options.pps = options.source + [options.dest]

    return options
Exemple #3
0
def parse_args(args):

    parser = ArgumentParser(description="Checks S3QL file system metadata")

    parser.add_log('~/.s3ql/fsck_db.log')
    parser.add_debug()
    parser.add_quiet()
    parser.add_version()

    def db_path(s):
        s = os.path.splitext(s)[0]
        if not os.path.exists(s + '.db'):
            raise ArgumentTypeError('Unable to read %s.db' % s)
        if not os.path.exists(s + '.params'):
            raise ArgumentTypeError('Unable to read %s.params' % s)
        return s

    parser.add_argument("path",
                        metavar='<path>',
                        type=db_path,
                        help='Database to be checked')

    options = parser.parse_args(args)

    return options
Exemple #4
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description='Measure S3QL write performance, uplink bandwidth and '
        'compression speed and determine limiting factor.')

    parser.add_quiet()
    parser.add_debug()
    parser.add_backend_options()
    parser.add_version()
    parser.add_storage_url()
    parser.add_argument('file',
                        metavar='<file>',
                        type=argparse.FileType(mode='rb'),
                        help='File to transfer')
    parser.add_argument(
        '--threads',
        metavar='<n>',
        type=int,
        default=None,
        help='Also include statistics for <n> threads in results.')

    parser.add_cachedir()
    return parser.parse_args(args)
Exemple #5
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(description=textwrap.dedent('''\
        ``expire_backups.py`` is a program to intelligently remove old backups
        that are no longer needed.

        To define what backups you want to keep for how long, you define a
        number of *age ranges*. ``expire_backups`` ensures that you will
        have at least one backup in each age range at all times. It will keep
        exactly as many backups as are required for that and delete any
        backups that become redundant.

        Age ranges are specified by giving a list of range boundaries in terms
        of backup cycles. Every time you create a new backup, the existing
        backups age by one cycle.

        Please refer to the S3QL documentation for details.
        '''))

    parser.add_quiet()
    parser.add_log()
    parser.add_debug()
    parser.add_version()

    parser.add_argument('cycles',
                        nargs='+',
                        type=int,
                        metavar='<age>',
                        help='Age range boundaries in terms of backup cycles')
    parser.add_argument(
        '--state',
        metavar='<file>',
        type=str,
        default='.expire_backups.dat',
        # Add quotes around default to prevent groff
        # from choking on leading . generated by buggy
        # docutils man page generator.
        help='File to save state information in (default: "%(default)s")')
    parser.add_argument(
        "-n",
        action="store_true",
        default=False,
        help="Dry run. Just show which backups would be deleted.")
    parser.add_argument(
        '--reconstruct-state',
        action='store_true',
        default=False,
        help='Try to reconstruct a missing state file from backup dates.')

    parser.add_argument("--use-s3qlrm",
                        action="store_true",
                        help="Use `s3qlrm` command to delete backups.")

    options = parser.parse_args(args)

    if sorted(options.cycles) != options.cycles:
        parser.error('Age range boundaries must be in increasing order')

    return options
Exemple #6
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(description='Clone an S3QL file system.')

    parser.add_quiet()
    parser.add_log()
    parser.add_debug()
    parser.add_backend_options()
    parser.add_version()

    parser.add_argument("--threads",
                        type=int,
                        default=3,
                        help='Number of threads to use')

    # Can't use parser.add_storage_url(), because we need both a source
    # and destination.
    parser.add_argument("--authfile",
                        type=str,
                        metavar='<path>',
                        default=os.path.expanduser("~/.s3ql/authinfo2"),
                        help='Read authentication credentials from this file '
                        '(default: `~/.s3ql/authinfo2)`')
    parser.add_argument(
        "src_storage_url",
        metavar='<source-storage-url>',
        type=storage_url_type,
        help='Storage URL of the source backend that contains the file system')
    parser.add_argument("dst_storage_url",
                        metavar='<destination-storage-url>',
                        type=storage_url_type,
                        help='Storage URL of the destination backend')

    options = parser.parse_args(args)
    setup_logging(options)

    # Print message so that the user has some idea what credentials are
    # wanted (if not specified in authfile).
    log.info('Connecting to source backend...')
    options.storage_url = options.src_storage_url
    parser._init_backend_factory(options)
    src_options = argparse.Namespace()
    src_options.__dict__.update(options.__dict__)
    options.src_backend_factory = lambda: src_options.backend_class(src_options
                                                                    )

    log.info('Connecting to destination backend...')
    options.storage_url = options.dst_storage_url
    parser._init_backend_factory(options)
    dst_options = argparse.Namespace()
    dst_options.__dict__.update(options.__dict__)
    options.dst_backend_factory = lambda: dst_options.backend_class(dst_options
                                                                    )
    del options.storage_url
    del options.backend_class

    return options
Exemple #7
0
def parse_args(args):

    parser = ArgumentParser(
        description="Create metadata copy where all file- and directory names, "
                    "and extended attribute names and values have been scrambled. "
                    "This is intended to preserve privacy when a metadata copy "
                    "needs to be provided to the developers for debugging.")

    parser.add_debug()
    parser.add_quiet()
    parser.add_version()
    parser.add_cachedir()
    parser.add_storage_url()

    options = parser.parse_args(args)

    return options
Exemple #8
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description='Batch remove objects from an S3QL backend')

    parser.add_storage_url()
    parser.add_quiet()
    parser.add_debug()
    parser.add_backend_options()
    parser.add_version()

    parser.add_argument(
        "file",
        type=argparse.FileType(mode='r', encoding='utf-8'),
        help='File with newline separated object keys to delete')

    return parser.parse_args(args)