offen / docker-volume-backup

Backup Docker volumes locally or to any S3, WebDAV, Azure Blob Storage, Dropbox or SSH compatible storage

Home Page:https://offen.github.io/docker-volume-backup/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Local backup not saving file

jimmyd-be opened this issue · comments

Describe the bug
I try to backup my postgres docker data to my NAS using the local archive functionality

To Reproduce
Steps to reproduce the behavior:
docker run --rm
-e BACKUP_FILENAME=postgres-%Y-%m-%dT%H-%M-%S.tar.gz
-e BACKUP_RETENTION_DAYS="7"
-e BACKUP_ARCHIVE=archive-postgres
-v /home/ubuntu/config/postgres-data:/backup/data:ro
-v /mnt/nas/postgres:/archive-postgres
-v /var/run/docker.sock:/var/run/docker.sock:ro
--entrypoint backup
offen/docker-volume-backup:v2

Expected behavior
The backup file should be in /mnt/nas/postgres

Version (please complete the following information):

  • Image Version: 2.33.2
  • Docker Version: 24.0.7
  • Docker Compose Version (if applicable):

Additional context

What's the log output when you run this command?

time=2023-12-03T10:57:23.989Z level=INFO msg="Stopping 1 container(s) labeled docker-volume-backup.stop-during-backup=true out of 11 running container(s)."
time=2023-12-03T10:59:33.103Z level=INFO msg="Created backup of /backup at /tmp/postgres-2023-12-03T10-57-23.tar.gz."
time=2023-12-03T10:59:34.080Z level=INFO msg="Restarted 1 container(s) and the matching service(s)."
time=2023-12-03T10:59:34.392Z level=INFO msg="Removed tar file /tmp/postgres-2023-12-03T10-57-23.tar.gz."
time=2023-12-03T10:59:34.392Z level=INFO msg="Finished running backup tasks."

From the log output it seems the command isn't even trying to copy the file anywhere as otherwise you'd see this log line:

b.Log(storage.LogLevelInfo, b.Name(), "Stored copy of backup `%s` in `%s`.", file, b.DestinationPath)

This means the following check fails on your setup

if _, err := os.Stat(s.c.BackupArchive); !os.IsNotExist(err) {
localConfig := local.Config{
ArchivePath: s.c.BackupArchive,
LatestSymlink: s.c.BackupLatestSymlink,
}
localBackend := local.NewStorageBackend(localConfig, logFunc)
s.storages = append(s.storages, localBackend)
}

and the command thinks the mounted path does not exist. Could it be that the container is not allowed to write to your NAS somehow?

Also, the value you pass to BACKUP_ARCHIVE is missing a leading slash, and should probably be /archive-postgres.

Adding the leasdin slash to the BACKUP_ARCHIVE it go Fatal error running backup: copyArchive: error copying archive: (*localStorage).Copy: Error copying file to archive: open /archive-postgres/postgres-2023-12-03T12-01-01.tar.gz: permission denied. Normally the user that is running the docker should have permissions to write to that directory. I will check further

i tried using a local directory and that worked.