Create a compressed backup of a Docker volume
Build a paste-ready command, then review its compatibility and effects before running it.
docker run --rm -v <volume>:/source:ro -v <destination>:/backup alpine tar -czf /backup/<archive-file> -C /source .Complete required fields to copy the generated command.
Compatibility
Linux + macOS + WindowsVerified for Linux, macOS, Windows using bash, zsh, powershell syntax.
Operational knowledgereview due 2027-01-19
Requirementsdockerdocker must be installed and available on PATH.
Version supportdocker Current supported releasesVerified for linux, macos, windows using bash, zsh, powershell syntax; consult compatibility notes for platform-specific differences.
Expected signalspgdata-2026-07-23.tar.gz created in ./backups (184.6 MiB)Representative successful output; values vary with the selected target and system state.
Known errorsdocker: command not founddocker is missing or is not available on PATH.
Verifydocker run --rm -v {{volume}}:/source:ro -v {{destination}}:/backup alpine tar -czf /backup/{{archiveFile}} -C /source .Re-run the corresponding read-only inspection and confirm the intended state.Rollback noteNo universal automatic rollback is available. Capture the current state and use the tool-specific recovery procedure before applying changes.
Command breakdown
01dockerCommandRuns the docker stage of this one-liner.
02runArgumentPasses run to docker.
03--rmOptionConfigures docker with the --rm option.
04-vOptionEnables verbose output for this command.
05<volume>:/source:roParameterA value supplied in the Fill parameters section.
06-vOptionEnables verbose output for this command.
07<destination>:/backupParameterA value supplied in the Fill parameters section.
08alpineArgumentPasses alpine to docker.
09tarArgumentPasses tar to docker.
10-czfOptionConfigures docker with the -czf option.
11/backup/<archive-file>ParameterA value supplied in the Fill parameters section.
12-COptionConfigures docker with the -C option.
13/sourceArgumentPasses /source to docker.
14.ArgumentPasses . to docker.
This advanced community-curated one-liner combines several stages. Review every option and placeholder before running it.
Example input
docker run --rm -v pgdata:/source:ro -v ./backups:/backup alpine tar -czf /backup/pgdata-2026-07-23.tar.gz -C /source .
Example output
pgdata-2026-07-23.tar.gz created in ./backups (184.6 MiB)
Illustrative output — exact values vary by system and data.
Official sources