Ejemplo n.º 1
0
// validate the config object
func validateConfig(backupConfig config.Config, driver *btrfs.Btrfs) error {

	// check to see if subvolume exists
	// do other sanity checks
	err := driver.Prepare(backupConfig)
	if err != nil {
		return err
	}

	// make sure that port number makes sense
	err = fmt.Errorf("Invalid port number: %d", backupConfig.DestinationPort)

	if backupConfig.DestinationPort > 65535 || backupConfig.DestinationPort < 1024 {
		return err
	}

	// do initial testing of system by listing subvolumes
	// and perform an initial snapshot for purposes of use later
	subvols, err := driver.Subvolumes(backupConfig)
	if err != nil && subvols == nil {
		return err
	}

	_, err2 := driver.Snapshot(backupConfig, "/")
	if err2 != nil {
		return err2
	}

	return nil
}