Beispiel #1
0
func (s3 S3ConnectionInfo) genBackupPath() string {
	t := time.Now()
	year, mon, day := t.Date()
	hour, min, sec := t.Clock()
	uuid := plugin.GenUUID()
	return fmt.Sprintf("%s/%04d/%02d/%02d/%04d-%02d-%02d-%02d%02d%02d-%s", s3.PathPrefix, year, mon, day, year, mon, day, hour, min, sec, uuid)
}
Beispiel #2
0
func (p FSPlugin) Store(endpoint plugin.ShieldEndpoint) (string, error) {
	cfg, err := getFSConfig(endpoint)
	if err != nil {
		return "", err
	}

	t := time.Now()
	year, mon, day := t.Date()
	hour, min, sec := t.Clock()
	uuid := plugin.GenUUID()

	dir := fmt.Sprintf("%04d/%02d/%02d", year, mon, day)
	file := fmt.Sprintf("%04d-%02d-%02d-%02d%02d%02d-%s", year, mon, day, hour, min, sec, uuid)

	err = os.MkdirAll(fmt.Sprintf("%s/%s", cfg.BasePath, dir), 0777) // umask will lower...
	if err != nil {
		return "", err
	}

	f, err := os.Create(fmt.Sprintf("%s/%s/%s", cfg.BasePath, dir, file))
	if err != nil {
		return "", err
	}
	defer f.Close()

	if _, err = io.Copy(f, os.Stdin); err != nil {
		return "", err
	}

	return fmt.Sprintf("%s/%s", dir, file), nil
}
Beispiel #3
0
func (s3 S3ConnectionInfo) genBackupPath() string {
	t := time.Now()
	year, mon, day := t.Date()
	hour, min, sec := t.Clock()
	uuid := plugin.GenUUID()
	path := fmt.Sprintf("%s/%04d/%02d/%02d/%04d-%02d-%02d-%02d%02d%02d-%s", s3.PathPrefix, year, mon, day, year, mon, day, hour, min, sec, uuid)
	// Remove double slashes
	path = strings.Replace(path, "//", "/", -1)
	return path
}
Beispiel #4
0
// Called when you want to store backup data. Examine the ShieldEndpoint passed in, and perform actions accordingly
func (p DummyPlugin) Store(endpoint plugin.ShieldEndpoint) (string, error) {
	directory, err := endpoint.StringValue("directory")
	if err != nil {
		return "", err
	}

	file := plugin.GenUUID()

	err = plugin.Exec(fmt.Sprintf("/bin/sh -c \"/bin/cat > %s/%s\"", directory, file), plugin.STDIN)
	return file, err
}