Here are some scripts that can be used to manually backup and restore data from Docker volumes.
Manual Docker Volume Backup
This script uses a temporary Docker container to mount the target volume. It also mounts the current directory so it can write the archive file.
Usage: backup-docker-volume.sh <Volume Name> <Backup File Name>
#!/bin/bash
#!/bin/bash
# Usage: backup-docker-volume.sh <Volume Name> [Backup File Name]
# Example 1: ./backup-docker-volume.sh n8n_n8n_data n8n_data_backup
# Example 2: ./backup-docker-volume.sh n8n_n8n_data
# Use this command to find the name of the volume:
# docker inspect --format '{{ json .Mounts }}' <container_name_or_id>
# 1. Capture the volume name
VOLUME_NAME=$1
# 2. Check if the second argument ($2) is provided.
# If not, default to "n8n_backup_" + current timestamp.
TIMESTAMP=$(date +"%Y_%m_%d_%H_%M_%S")
BACKUP_NAME=${2:-"n8n_backup_$TIMESTAMP"}
# 3. Run the backup
docker run --rm \
-v "$VOLUME_NAME":/source:ro \
-v "$(pwd)":/backup \
alpine tar czf /backup/"$BACKUP_NAME".tar.gz -C /source .
echo "Backup completed: ${BACKUP_NAME}.tar.gz"
Restore a Manual Backup
This script: