Пример #1
0
func (b *backuper) Backup(client redis.Client, s3TargetPath string) error {
	localLogger := b.logger.WithData(lager.Data{
		"redis_address": client.Address(),
	})

	localLogger.Info("backup", lager.Data{"event": "starting"})

	snapshotter := b.snapshotterProvider(client, b.snapshotTimeout, b.logger)
	artifact, err := snapshotter.Snapshot()
	if err != nil {
		localLogger.Error("backup", err, lager.Data{"event": "failed"})
		return err
	}

	originalPath := artifact.Path()

	tmpSnapshotPath := filepath.Join(b.tmpDir, uuid.New())

	renameTask := b.renameTaskProvider(tmpSnapshotPath, b.logger)

	uploadTask := b.s3UploadTaskProvider(
		b.s3BucketName,
		s3TargetPath,
		b.s3Endpoint,
		b.awsAccessKey,
		b.awsSecretKey,
		b.logger,
	)

	cleanupTask := b.cleanupTaskProvider(
		originalPath,
		tmpSnapshotPath,
		b.logger,
	)

	artifact, err = task.NewPipeline(
		"redis-backup",
		b.logger,
		renameTask,
		uploadTask,
	).Run(artifact)

	if err != nil {
		localLogger.Error("backup", err, lager.Data{"event": "failed"})
	}

	task.NewPipeline(
		"cleanup",
		b.logger,
		cleanupTask,
	).Run(artifact)

	localLogger.Info("backup", lager.Data{"event": "done"})

	return err
}
Пример #2
0
		var redisClient client.Client

		BeforeEach(func() {
			redisRunner = &integration.RedisRunner{}
			redisRunner.Start(redisArgs)
			var err error
			redisClient, err = client.Connect(client.Host(host), client.Port(port))
			Expect(err).ToNot(HaveOccurred())
		})

		AfterEach(func() {
			redisRunner.Stop()
		})

		It("returns an address that consists of the client's host and port", func() {
			Expect(redisClient.Address()).To(Equal(fmt.Sprintf("%s:%d", host, port)))
		})
	})

	Describe(".GetConfig", func() {
		var redisClient client.Client

		BeforeEach(func() {
			redisRunner = &integration.RedisRunner{}
			redisRunner.Start(redisArgs)

			var err error
			redisClient, err = client.Connect(
				client.Host(host),
				client.Port(port),
			)