diff --git a/cmd/root.go b/cmd/root.go index 5581f23..79b7439 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -408,7 +408,7 @@ __ [blue][bold]Pterodactyl[reset] _____/___/_______ _______ ______ \___/\___/___/___/___/___ /______/ /_______/ [bold]v%s[reset] -Copyright © 2018 - 2020 Dane Everitt & Contributors +Copyright © 2018 - 2021 Dane Everitt & Contributors Website: https://pterodactyl.io Source: https://github.com/pterodactyl/wings diff --git a/server/backup/backup.go b/server/backup/backup.go index 9743f45..46e20b9 100644 --- a/server/backup/backup.go +++ b/server/backup/backup.go @@ -116,11 +116,14 @@ func (b *Backup) Details() *ArchiveDetails { wg := sync.WaitGroup{} wg.Add(2) + l := log.WithField("backup_id", b.Uuid) + var checksum string // Calculate the checksum for the file. go func() { defer wg.Done() + l.Info("computing checksum for backup..") resp, err := b.Checksum() if err != nil { log.WithFields(log.Fields{ @@ -131,6 +134,7 @@ func (b *Backup) Details() *ArchiveDetails { } checksum = hex.EncodeToString(resp) + l.WithField("checksum", checksum).Info("computed checksum for backup") }() var sz int64 diff --git a/server/backup/backup_local.go b/server/backup/backup_local.go index 2e14637..dbea642 100644 --- a/server/backup/backup_local.go +++ b/server/backup/backup_local.go @@ -2,6 +2,7 @@ package backup import ( "errors" + "github.com/apex/log" "github.com/pterodactyl/wings/server/filesystem" "os" ) @@ -47,9 +48,16 @@ func (b *LocalBackup) Generate(basePath, ignore string) (*ArchiveDetails, error) Ignore: ignore, } + l := log.WithFields(log.Fields{ + "backup_id": b.Uuid, + "adapter": "local", + }) + + l.Info("attempting to create backup..") if err := a.Create(b.Path()); err != nil { return nil, err } + l.Info("created backup successfully.") return b.Details(), nil } diff --git a/server/backup/backup_s3.go b/server/backup/backup_s3.go index cbb6ed3..1f8bd9a 100644 --- a/server/backup/backup_s3.go +++ b/server/backup/backup_s3.go @@ -27,9 +27,16 @@ func (s *S3Backup) Generate(basePath, ignore string) (*ArchiveDetails, error) { Ignore: ignore, } + l := log.WithFields(log.Fields{ + "backup_id": s.Uuid, + "adapter": "s3", + }) + + l.Info("attempting to create backup..") if err := a.Create(s.Path()); err != nil { return nil, err } + l.Info("created backup successfully.") rc, err := os.Open(s.Path()) if err != nil { @@ -63,22 +70,26 @@ func (Reader) Close() error { func (s *S3Backup) generateRemoteRequest(rc io.ReadCloser) error { defer rc.Close() - size, err := s.Backup.Size() - if err != nil { - return err - } - - urls, err := api.New().GetBackupRemoteUploadURLs(s.Backup.Uuid, size) - if err != nil { - return err - } - l := log.WithFields(log.Fields{ "backup_id": s.Uuid, "adapter": "s3", }) - l.Info("attempting to upload backup..") + l.Debug("attempting to get size of backup..") + size, err := s.Backup.Size() + if err != nil { + return err + } + l.WithField("size", size).Debug("got size of backup") + + l.Debug("attempting to get S3 upload urls from Panel..") + urls, err := api.New().GetBackupRemoteUploadURLs(s.Backup.Uuid, size) + if err != nil { + return err + } + l.Debug("got S3 upload urls from the Panel") + partCount := len(urls.Parts) + l.WithField("parts", partCount).Info("attempting to upload backup..") handlePart := func(part string, size int64) (string, error) { r, err := http.NewRequest(http.MethodPut, part, nil) @@ -111,7 +122,6 @@ func (s *S3Backup) generateRemoteRequest(rc io.ReadCloser) error { return res.Header.Get("ETag"), nil } - partCount := len(urls.Parts) for i, part := range urls.Parts { // Get the size for the current part. var partSize int64 @@ -128,6 +138,8 @@ func (s *S3Backup) generateRemoteRequest(rc io.ReadCloser) error { l.WithField("part_id", part).WithError(err).Warn("failed to upload part") return err } + + l.WithField("part_id", part).Info("successfully uploaded backup part.") } l.WithField("parts", partCount).Info("backup has been successfully uploaded") diff --git a/server/filesystem/archive.go b/server/filesystem/archive.go index df95db2..347e8cb 100644 --- a/server/filesystem/archive.go +++ b/server/filesystem/archive.go @@ -152,7 +152,12 @@ func (a *Archive) addToArchive(p string, rp string, w *tar.Writer) error { if s.Mode()&os.ModeSymlink != 0 { // Read the target of the symlink. target, err = os.Readlink(s.Name()) - if err != nil && !os.IsNotExist(err) { + if err != nil { + // Skip symlinks if the target does not exist. + if os.IsNotExist(err) { + return nil + } + return errors.WithMessagef(err, "failed to read symlink target for '%s'", rp) } }