in s3plugin/backup.go [65:107]
func BackupDirectory(c *cli.Context) error {
start := time.Now()
totalBytes := int64(0)
config, sess, err := readConfigAndStartSession(c)
if err != nil {
return err
}
dirName := c.Args().Get(1)
gplog.Verbose("Restore Directory '%s' from S3", dirName)
gplog.Verbose("S3 Location = s3://%s/%s", config.Options.Bucket, dirName)
gplog.Info("dirKey = %s\n", dirName)
// Populate a list of files to be backed up
fileList := make([]string, 0)
_ = filepath.Walk(dirName, func(path string, f os.FileInfo, err error) error {
isDir, _ := isDirectoryGetSize(path)
if !isDir {
fileList = append(fileList, path)
}
return nil
})
// Process the files sequentially
for _, fileName := range fileList {
file, err := os.Open(fileName)
if err != nil {
return err
}
bytes, elapsed, err := uploadFile(sess, config, fileName, file)
_ = file.Close()
if err != nil {
return err
}
totalBytes += bytes
gplog.Debug("Uploaded %d bytes for %s in %v", bytes,
filepath.Base(fileName), elapsed.Round(time.Millisecond))
}
gplog.Info("Uploaded %d files (%d bytes) in %v\n", len(fileList),
totalBytes, time.Since(start).Round(time.Millisecond))
return nil
}