Docker Community Forums

Share and learn in the Docker community.

Volume backup not being created

I am trying to follow the example in the documentation for creating a backup of a volume. However I am not finding any backup.tar anywhere after running the command.

From the docker documentation:

Backup a container

For example, in the next command, we:

Launch a new container and mount the volume from the dbstore container
Mount a local host directory as /backup
Pass a command that tars the contents of the dbdata volume to a backup.tar file inside our /backup directory.

$ docker run --rm --volumes-from dbstore -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata

When the command completes and the container stops, we are left with a backup of our dbdata volume.

I ran this command replacing the example names with the ones of my actual project, but yet a backup.tar is nowhere to be seen. When I run through the command it prints out the contents of the volume im backing up so I know its finding the right one and everything but I see no backup file. Is this supposed to end up on the host machine? on the container being backed up? in the temporary container used to create the backup? im confused.

I am also trying to follow the one here, but same result, no backup.tar

Yes, it is supposed to appear in the folder from where you execute the docker run command. -v $(pwd):/backup mounts the current folder as /backup into the container. If the file does’t appear then probably the volume mount doesn’t work. On what OS are you working?