def configure_backups_rotation(profile="default"): rotation_conf = {"rotation": {}} rotation_conf["rotation"]["days"] = int( raw_input("Number of days to keep: ")) rotation_conf["rotation"]["weeks"] = int( raw_input("Number of weeks to keep: ")) rotation_conf["rotation"]["months"] = int( raw_input("Number of months to keep: ")) while 1: first_week_day = raw_input( "First week day (to calculate wich weekly backup keep, saturday by default): " ) if first_week_day: if hasattr(calendar, first_week_day.upper()): first_week_day = getattr(calendar, first_week_day.upper()) break else: log.error( "Invalid first_week_day, please choose from sunday to saturday." ) else: first_week_day = calendar.SATURDAY break rotation_conf["rotation"]["first_week_day"] = int(first_week_day) conf_file = open(CONFIG_FILE, "w") new_conf = config.copy() new_conf[profile].update(rotation_conf) yaml.dump(new_conf, conf_file, default_flow_style=False) log.info("Config written in %s" % CONFIG_FILE)
def configure(profile="default"): new_conf = config.copy() new_conf[profile] = config.get(profile, {}) new_conf_file = open(CONFIG_FILE, "w") new_conf[profile]["access_key"] = raw_input("AWS Access Key: ") new_conf[profile]["secret_key"] = raw_input("AWS Secret Key: ") new_conf[profile]["s3_bucket"] = raw_input("S3 Bucket Name: ") new_conf[profile]["glacier_vault"] = raw_input("Glacier Vault Name: ") while 1: default_destination = raw_input("Default destination ({0}): ".format(DEFAULT_DESTINATION)) if default_destination: default_destination = default_destination.lower() if default_destination in ("s3", "glacier"): break else: log.error("Invalid default_destination, should be s3 or glacier, try again.") else: default_destination = DEFAULT_DESTINATION break new_conf[profile]["default_destination"] = default_destination region_name = raw_input("Region Name ({0}): ".format(DEFAULT_LOCATION)) if not region_name: region_name = DEFAULT_LOCATION new_conf[profile]["region_name"] = region_name yaml.dump(new_conf, new_conf_file, default_flow_style=False) log.info("Config written in %s" % CONFIG_FILE) log.info("Run bakthat configure_backups_rotation if needed.")
def configure(profile="default"): try: new_conf = config.copy() new_conf[profile] = config.get(profile, {}) while 1: database_type = raw_input("Database type: ") if database_type: database_type = database_type.lower() if database_type in ("mysql", "sqlite"): break else: log.error("Invalid database_type, should be mysql or sqlite, try again.") new_conf[profile]["database_type"] = database_type if database_type == "mysql": new_conf[profile]["database_host"] = raw_input("Database host: ") new_conf[profile]["database_name"] = raw_input("Database name: ") new_conf[profile]["database_user"] = raw_input("Database user: "******"database_pass"] = raw_input("Database pass: "******"database_port"] = raw_input("Database port: ") new_conf[profile]["access_key"] = raw_input("AWS Access Key: ") new_conf[profile]["secret_key"] = raw_input("AWS Secret Key: ") new_conf[profile]["s3_bucket"] = raw_input("S3 Bucket Name: ") new_conf[profile]["glacier_vault"] = raw_input("Glacier Vault Name: ") while 1: default_destination = raw_input("Default destination ({0}): ".format(DEFAULT_DESTINATION)) if default_destination: default_destination = default_destination.lower() if default_destination in ("s3", "glacier", "swift"): break else: log.error("Invalid default_destination, should be s3 or glacier, swift, try again.") else: default_destination = DEFAULT_DESTINATION break new_conf[profile]["default_destination"] = default_destination region_name = raw_input("Region Name ({0}): ".format(DEFAULT_LOCATION)) if not region_name: region_name = DEFAULT_LOCATION new_conf[profile]["region_name"] = region_name if default_destination in ("swift"): new_conf[profile]["auth_version"] = raw_input("Swift Auth Version: ") new_conf[profile]["auth_url"] = raw_input("Swift Auth URL: ") yaml.dump(new_conf, open(CONFIG_FILE, "w"), default_flow_style=False) log.info("Config written in %s" % CONFIG_FILE) log.info("Run bakthat configure_backups_rotation if needed.") except KeyboardInterrupt: log.error("Cancelled by user")
def configure(profile="default"): try: new_conf = config.copy() new_conf[profile] = config.get(profile, {}) new_conf[profile]["access_key"] = raw_input("AWS Access Key: ") new_conf[profile]["secret_key"] = raw_input("AWS Secret Key: ") new_conf[profile]["s3_bucket"] = raw_input("S3 Bucket Name: ") new_conf[profile]["glacier_vault"] = raw_input("Glacier Vault Name: ") while 1: default_destination = raw_input( "Default destination ({0}): ".format(DEFAULT_DESTINATION)) if default_destination: default_destination = default_destination.lower() if default_destination in ("s3", "glacier", "swift"): break else: log.error( "Invalid default_destination, should be s3 or glacier, swift, try again." ) else: default_destination = DEFAULT_DESTINATION break new_conf[profile]["default_destination"] = default_destination region_name = raw_input("Region Name ({0}): ".format(DEFAULT_LOCATION)) if not region_name: region_name = DEFAULT_LOCATION new_conf[profile]["region_name"] = region_name if default_destination in ("swift"): new_conf[profile]["auth_version"] = raw_input( "Swift Auth Version: ") new_conf[profile]["auth_url"] = raw_input("Swift Auth URL: ") yaml.dump(new_conf, open(CONFIG_FILE, "w"), default_flow_style=False) log.info("Config written in %s" % CONFIG_FILE) log.info("Run bakthat configure_backups_rotation if needed.") except KeyboardInterrupt: log.error("Cancelled by user")
def configure_backups_rotation(profile="default"): rotation_conf = {"rotation": {}} rotation_conf["rotation"]["days"] = int(raw_input("Number of days to keep: ")) rotation_conf["rotation"]["weeks"] = int(raw_input("Number of weeks to keep: ")) rotation_conf["rotation"]["months"] = int(raw_input("Number of months to keep: ")) while 1: first_week_day = raw_input("First week day (to calculate wich weekly backup keep, saturday by default): ") if first_week_day: if hasattr(calendar, first_week_day.upper()): first_week_day = getattr(calendar, first_week_day.upper()) break else: log.error("Invalid first_week_day, please choose from sunday to saturday.") else: first_week_day = calendar.SATURDAY break rotation_conf["rotation"]["first_week_day"] = int(first_week_day) conf_file = open(CONFIG_FILE, "w") new_conf = config.copy() new_conf[profile].update(rotation_conf) yaml.dump(new_conf, conf_file, default_flow_style=False) log.info("Config written in %s" % CONFIG_FILE)