def main(): subparsers = base_parser.add_subparsers(title='subcommands', dest='subcommand') base_parser.add_argument('--incremental_backups', action='store_true', default=False) put_parser = subparsers.add_parser('put', help='put files on s3 from a manifest') manifest_parser = subparsers.add_parser( 'create-upload-manifest', help='put files on s3 from a manifest') # put arguments put_parser = add_s3_arguments(put_parser) put_parser.add_argument( '--manifest', required=True, help='The manifest containing the files to put on s3') put_parser.add_argument('--concurrency', required=False, default=DEFAULT_CONCURRENCY, type=int, help='Compress and upload concurrent processes') # create-upload-manifest arguments manifest_parser.add_argument('--snapshot_name', required=True, type=str) manifest_parser.add_argument('--snapshot_keyspaces', default='', required=False, type=str) manifest_parser.add_argument('--snapshot_table', required=False, default='', type=str) manifest_parser.add_argument('--data_path', required=True, type=str) manifest_parser.add_argument('--manifest_path', required=True, type=str) args = base_parser.parse_args() subcommand = args.subcommand if subcommand == 'create-upload-manifest': create_upload_manifest(args.snapshot_name, args.snapshot_keyspaces, args.snapshot_table, args.data_path, args.manifest_path, args.incremental_backups) if subcommand == 'put': check_lzop() put_from_manifest(args.s3_bucket_name, get_s3_connection_host(args.s3_bucket_region), args.s3_ssenc, args.s3_base_path, args.aws_access_key_id, args.aws_secret_access_key, args.manifest, args.concurrency, args.incremental_backups)
def main(): subparsers = base_parser.add_subparsers(title='subcommands', dest='subcommand') base_parser.add_argument('--incremental_backups', action='store_true', default=False) put_parser = subparsers.add_parser('put', help='put files on s3 from a manifest') manifest_parser = subparsers.add_parser('create-upload-manifest', help='put files on s3 from a manifest') # put arguments put_parser = add_s3_arguments(put_parser) put_parser.add_argument('--manifest', required=True, help='The manifest containing the files to put on s3') put_parser.add_argument('--concurrency', required=False, default=DEFAULT_CONCURRENCY, type=int, help='Compress and upload concurrent processes') # create-upload-manifest arguments manifest_parser.add_argument('--snapshot_name', required=True, type=str) manifest_parser.add_argument('--snapshot_keyspaces', default='', required=False, type=str) manifest_parser.add_argument('--snapshot_table', required=False, default='', type=str) manifest_parser.add_argument('--data_path', required=True, type=str) manifest_parser.add_argument('--manifest_path', required=True, type=str) args = base_parser.parse_args() subcommand = args.subcommand if subcommand == 'create-upload-manifest': create_upload_manifest( args.snapshot_name, args.snapshot_keyspaces, args.snapshot_table, args.data_path, args.manifest_path, args.incremental_backups ) if subcommand == 'put': check_lzop() put_from_manifest( args.s3_bucket_name, get_s3_connection_host(args.s3_bucket_region), args.s3_ssenc, args.s3_base_path, args.aws_access_key_id, args.aws_secret_access_key, args.manifest, args.concurrency, args.incremental_backups )
def main(): base_parser = add_s3_arguments(_base_parser) subparsers = base_parser.add_subparsers(title='subcommands', dest='subcommand') subparsers.add_parser('list', help='list existing backups') backup_parser = subparsers.add_parser('backup', help='create a snapshot') # snapshot / backup arguments backup_parser.add_argument('--hosts', required=True, help='The comma separated list of hosts to snapshot') backup_parser.add_argument('--keyspaces', default='', help='The keyspaces to backup (omit to backup all)') backup_parser.add_argument('--table', default='', help='The table (column family) to backup') backup_parser.add_argument('--cassandra-data-path', default='/var/lib/cassandra/data/', help='cassandra data path.') backup_parser.add_argument('--nodetool-path', default=None, help='nodetool path.') backup_parser.add_argument('--cassandra-bin-dir', default='/usr/bin', help='cassandra binaries directory') backup_parser.add_argument('--user', help='the ssh user to logging on nodes') backup_parser.add_argument('--sshport', help='the ssh port to use to connect to the nodes') backup_parser.add_argument('--password', default='', help='user password to connect with hosts') backup_parser.add_argument('--new-snapshot', action='store_true', help='create a new snapshot') backup_parser.add_argument('--backup-schema', action='store_true', help='Backup (thrift) schema of selected keyspaces') backup_parser.add_argument('--connection-pool-size', default=12, help='Number of simultaneous connections to cassandra nodes.') # restore snapshot arguments restore_parser = subparsers.add_parser('restore', help='restores a snapshot') restore_parser.add_argument('--snapshot-name', default='LATEST', help='The name (date/time) of the snapshot (and incrementals) to restore') restore_parser.add_argument('--keyspace', required=True, help='The keyspace to restore') restore_parser.add_argument('--table', default='', help='The table (column family) to restore; leave blank for all') restore_parser.add_argument('--hosts', default='', help='Comma separated list of hosts to restore from; leave empty for all') restore_parser.add_argument('--target-hosts', required=True, help="The comma separated list of hosts to restore into") args = base_parser.parse_args() subcommand = args.subcommand if args.verbose: logging.basicConfig(level=logging.INFO) if subcommand == 'backup': run_backup(args) elif subcommand == 'list': list_backups(args) elif subcommand == 'restore': restore_backup(args)
def main(): base_parser = add_s3_arguments(_base_parser) subparsers = base_parser.add_subparsers(title='subcommands', dest='subcommand') subparsers.add_parser('list', help='list existing backups') backup_parser = subparsers.add_parser('backup', help='create a snapshot') # snapshot / backup arguments backup_parser.add_argument( '--hosts', required=True, help='The comma separated list of hosts to snapshot') backup_parser.add_argument( '--keyspaces', default='', help='The keyspaces to backup (omit to backup all)') backup_parser.add_argument('--table', default='', help='The table (column family) to backup') backup_parser.add_argument('--cassandra-data-path', default='/var/lib/cassandra/data/', help='cassandra data path.') backup_parser.add_argument('--nodetool-path', default=None, help='nodetool path.') backup_parser.add_argument('--cassandra-bin-dir', default='/usr/bin', help='cassandra binaries directory') backup_parser.add_argument('--user', help='the ssh user to loging on nodes') backup_parser.add_argument('--password', default='', help='user password to connect with hosts') backup_parser.add_argument('--new-snapshot', action='store_true', help='create a new snapshot') backup_parser.add_argument( '--backup-schema', action='store_true', help='Backup (thrift) schema of selected keyspaces') backup_parser.add_argument( '--connection-pool-size', default=12, help='Number of simultaneous connections to cassandra nodes.') # restore snapshot arguments restore_parser = subparsers.add_parser('restore', help='restores a snapshot') restore_parser.add_argument( '--snapshot-name', default='LATEST', help= 'The name (date/time) of the snapshot (and incrementals) to restore') restore_parser.add_argument('--keyspace', required=True, help='The keyspace to restore') restore_parser.add_argument( '--table', default='', help='The table (column family) to restore; leave blank for all') restore_parser.add_argument( '--hosts', default='', help= 'Comma separated list of hosts to restore from; leave empty for all') restore_parser.add_argument( '--target-hosts', required=True, help="The comma separated list of hosts to restore into") args = base_parser.parse_args() subcommand = args.subcommand if args.verbose: logging.basicConfig(level=logging.INFO) if subcommand == 'backup': run_backup(args) elif subcommand == 'list': list_backups(args) elif subcommand == 'restore': restore_backup(args)
def main(): a_base_parser = add_s3_arguments(base_parser) subparsers = a_base_parser.add_subparsers(title='subcommands', dest='subcommand') subparsers.add_parser('list', help="List existing backups") backup_parser = subparsers.add_parser('backup', help="Create a snapshot") # snapshot / backup arguments backup_parser.add_argument( '--buffer-size', default=64, help="The buffer size (MB) for compress and upload") backup_parser.add_argument('--exclude-tables', default='', help="Column families you want to skip") backup_parser.add_argument( '--hosts', required=True, help= "Comma separated list of hosts to snapshot (only one with --use-local)" ) backup_parser.add_argument( '--keyspaces', default='', help="Comma separated list of keyspaces to backup (omit to backup all)" ) backup_parser.add_argument('--table', default='', help="The table (column family) to backup") backup_parser.add_argument('--cassandra-conf-path', default='/etc/cassandra/', help="cassandra config file path") backup_parser.add_argument( '--cassandra-tools-bin-dir', default='/usr/bin', help="binary directory for nodetool, cqlsh and sstableloader") backup_parser.add_argument('--user', help="The ssh user to logging on nodes") backup_parser.add_argument('--use-sudo', default=False, help="Use sudo to run backup") backup_parser.add_argument( '--use-local', default=False, help= "Run the backup locally. If so, `hosts` must be one string determining the folder to backup into S3, " "so it can be differentiated from other nodes backups") backup_parser.add_argument( '--sudo-user', default=None, help="Run sudo as an user other than the default (root)") backup_parser.add_argument( '--sshport', help="The ssh port to use to connect to the nodes") backup_parser.add_argument('--password', default='', help="User password to connect with hosts") backup_parser.add_argument( '--sshkey', help= "The file containing the private ssh key to use to connect with hosts") backup_parser.add_argument('--new-snapshot', action='store_true', help="Create a new snapshot") backup_parser.add_argument( '--backup-schema', action='store_true', help="Backup (thrift) schema of selected keyspaces") backup_parser.add_argument('--cqlsh-user', default='', help="User to use for cqlsh commands") backup_parser.add_argument('--cqlsh-password', default='', help="Password to use for cqlsh commands") backup_parser.add_argument( '--connection-pool-size', default=12, help="Number of simultaneous connections to cassandra nodes") backup_parser.add_argument('--reduced-redundancy', action='store_true', help="Use S3 reduced redundancy") backup_parser.add_argument( '--rate-limit', default=0, help= "Limit the upload speed to S3 (by using 'pv'). Value expressed in kilobytes (*1024)" ) backup_parser.add_argument( '--quiet', action='store_true', help="Set pv in quiet mode when using --rate-limit. " "Useful when called by a script.") backup_parser.add_argument( '--nice', default=0, help= "Nice argument for process to prioritize CPU and IO workload (only with --use-local) " ) backup_parser.add_argument('--timestamp', default='%Y%m%d', help="Set timestamp to snapshots folder ") # restore snapshot arguments restore_parser = subparsers.add_parser('restore', help="Restores a snapshot") restore_parser.add_argument( '--snapshot-name', default='LATEST', help="The name of the snapshot (and incremental backups) to restore") restore_parser.add_argument('--keyspace', required=True, help="The keyspace to restore") restore_parser.add_argument('--user', help="The ssh user to logging on nodes") restore_parser.add_argument('--use-sudo', default=False, help="Use sudo to restore the backup") restore_parser.add_argument('--use-local', default=False, help="Fetch a backup locally.") restore_parser.add_argument( '--sudo-user', default=None, help="Run sudo as an user other than the default (root)") restore_parser.add_argument( '--sshport', help="The ssh port to use to connect to the nodes") restore_parser.add_argument('--password', default='', help="User password to connect with hosts") restore_parser.add_argument( '--sshkey', help= "The file containing the private ssh key to use to connect with hosts") restore_parser.add_argument('--host', required=True, help="Cassandra host to restore into") restore_parser.add_argument( '--cassandra-tools-bin-dir', default='/usr/bin', help="binary directory for nodetool, cqlsh and sstableloader") restore_parser.add_argument('--restore-dir', default='/tmp/cassandra_restore', help="directory to recover the backup to") args = a_base_parser.parse_args() subcommand = args.subcommand if args.verbose: logging.basicConfig(level=logging.INFO) if subcommand == 'backup': run_backup(args) elif subcommand == 'list': list_backups(args) elif subcommand == 'restore': restore_backup(args)
def main(): base_parser = add_s3_arguments(_base_parser) subparsers = base_parser.add_subparsers(title='subcommands', dest='subcommand') subparsers.add_parser('list', help='list existing backups') backup_parser = subparsers.add_parser('backup', help='create a snapshot') # snapshot / backup arguments backup_parser.add_argument('--hosts', default='', help='The comma separated list of hosts to snapshot (omit to run locally)') backup_parser.add_argument('--keyspaces', default='', help='The keyspaces to backup (omit to backup all)') backup_parser.add_argument('--table', default='', help='The table (column family) to backup') backup_parser.add_argument('--cassandra-data-path', default='/var/lib/cassandra/data/', help='cassandra data path.') backup_parser.add_argument('--cassandra-bin-dir', default='/usr/bin', help='cassandra binaries directory') backup_parser.add_argument('--nodetool-path', default=None, help='nodetool path.') backup_parser.add_argument('--agent-path', default=None, help='path of cassandra-snapshotter-agent on nodes') backup_parser.add_argument('--agent-virtualenv', default=None, help='python virtualenv to run cassandra-snapshotter-agent in on nodes') backup_parser.add_argument('--user', help='the ssh user to logging on nodes') backup_parser.add_argument('--sshport', help='the ssh port to use to connect to the nodes') backup_parser.add_argument('--sshkey', help='the file containing the private ssh key to use to connect to the nodes') backup_parser.add_argument('--password', default='', help='user password to connect with hosts') backup_parser.add_argument('--no-sudo', action='store_true', help='Do not use \'sudo\' when executing commands on the cassandra nodes') backup_parser.add_argument('--new-snapshot', action='store_true', help='create a new snapshot') backup_parser.add_argument('--delete-old-snapshots', action='store_true', help='Deletes any old snapshots from the nodes (not from S3!). ' 'Helpful when a previous run had --keep-new-snapshot set') backup_parser.add_argument('--keep-new-snapshot', action='store_true', help='Do not delete the new snapshot after upload to S3. ' 'Requires --new-snapshot') backup_parser.add_argument('--delete-incremental-backups', action='store_true', help='Empty Cassandra\'s incremental \'backups\' directory on the nodes. ' 'Requires --new-snapshot, --cassandra-data-path and (currently) --keyspaces') backup_parser.add_argument('--backup-schema', action='store_true', help='Backup (thrift) schema of selected keyspaces') backup_parser.add_argument('--connection-pool-size', default=12, help='Number of simultaneous connections to cassandra nodes.') # restore snapshot arguments restore_parser = subparsers.add_parser('restore', help='restores a snapshot') restore_parser.add_argument('--snapshot-name', default='LATEST', help='The name (date/time) of the snapshot (and incrementals) to restore') restore_parser.add_argument('--keyspace', required=True, help='The keyspace to restore') restore_parser.add_argument('--table', default='', help='The table (column family) to restore; leave blank for all') restore_parser.add_argument('--hosts', default='', help='Comma separated list of hosts to restore from; leave empty for all') restore_parser.add_argument('--target-hosts', required=True, help="The comma separated list of hosts to restore into") restore_parser.add_argument('--local-source', default=None, help="Local directory containing a version of the backups as generated by the snapshotter") restore_parser.add_argument('--merge-dir', default='.', help="Parent of the temp folder storing the merge SSTables of all backups") args = base_parser.parse_args() subcommand = args.subcommand if args.verbose: logging.basicConfig(level=logging.INFO) if subcommand == 'backup': run_backup(args) elif subcommand == 'list': list_backups(args) elif subcommand == 'restore': restore_backup(args)