fix location of success message for having created local backup

This commit is contained in:
Frederik Ring 2021-08-22 20:42:25 +02:00
parent 935de92f2e
commit 7244725c5b
2 changed files with 7 additions and 8 deletions

View File

@ -176,9 +176,9 @@ docker exec <container_ref> backup
This image is heavily inspired by the `futurice/docker-volume-backup`. We decided to publish this image as a simpler and more lightweight alternative because of the following requirements: This image is heavily inspired by the `futurice/docker-volume-backup`. We decided to publish this image as a simpler and more lightweight alternative because of the following requirements:
- The original image is based on `ubuntu`, making it very heavy. This version is roughly 1/3 in compressed size. - The original image is based on `ubuntu` and additional tools, making it very heavy. This version is roughly 1/25 in compressed size (it's ~12MB).
- The original image uses a shell script, when this is written in Go. - The original image uses a shell script, when this is written in Go.
- The original image proposed to handle backup rotation through AWS S3 lifecycle policies. This image adds the option to rotate away old backups through the same command so this functionality can also be offered for non-AWS storage backends like MinIO. Local backups can also be pruned once they reach a certain age. - The original image proposed to handle backup rotation through AWS S3 lifecycle policies. This image adds the option to rotate away old backups through the same command so this functionality can also be offered for non-AWS storage backends like MinIO. Local copies of backups can also be pruned once they reach a certain age.
- InfluxDB specific functionality was removed. - InfluxDB specific functionality was removed.
- `arm64` and `arm/v7` architectures are supported. - `arm64` and `arm/v7` architectures are supported.
- Docker in Swarm mode is supported. - Docker in Swarm mode is supported.

View File

@ -41,6 +41,7 @@ func main() {
s.must(s.copyBackup()) s.must(s.copyBackup())
s.must(s.cleanBackup()) s.must(s.cleanBackup())
s.must(s.pruneOldBackups()) s.must(s.pruneOldBackups())
s.logger.Info("Finished running backup tasks.")
} }
type script struct { type script struct {
@ -305,11 +306,9 @@ func (s *script) copyBackup() error {
s.logger.Infof("Successfully uploaded a copy of backup `%s` to bucket `%s`", s.file, s.bucket) s.logger.Infof("Successfully uploaded a copy of backup `%s` to bucket `%s`", s.file, s.bucket)
} }
if s.archive != "" { if _, err := os.Stat(s.archive); !os.IsNotExist(err) {
if _, err := os.Stat(s.archive); !os.IsNotExist(err) { if err := copy(s.file, path.Join(s.archive, name)); err != nil {
if err := copy(s.file, path.Join(s.archive, name)); err != nil { return fmt.Errorf("copyBackup: error copying file to local archive: %w", err)
return fmt.Errorf("copyBackup: error copying file to local archive: %w", err)
}
} }
s.logger.Infof("Successfully stored copy of backup `%s` in local archive `%s`", s.file, s.archive) s.logger.Infof("Successfully stored copy of backup `%s` in local archive `%s`", s.file, s.archive)
} }
@ -404,7 +403,7 @@ func (s *script) pruneOldBackups() error {
} }
} }
if s.archive != "" { if _, err := os.Stat(s.archive); !os.IsNotExist(err) {
candidates, err := filepath.Glob( candidates, err := filepath.Glob(
path.Join(s.archive, fmt.Sprintf("%s*", os.Getenv("BACKUP_PRUNING_PREFIX"))), path.Join(s.archive, fmt.Sprintf("%s*", os.Getenv("BACKUP_PRUNING_PREFIX"))),
) )