- Replace `USERNAME` and `TARGET_USERNAME` with `USER` and `TARGET_USER` in `bin/upgrade-odoo` to align with existing environment variable conventions - Update SSH command construction in `upgrade-odoo` to use the standardized user variables - Refactor `roles/docker/files/docker-export` to stream tar content directly to the destination file, eliminating temporary file creation inside the container - Refactor `roles/docker/files/docker-import` to stream tar content directly from the source file, removing the need for intermediate file transfer and cleanup - Update log messages in both scripts to reflect the streaming approach
56 lines
1.4 KiB
Bash
Executable File
56 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
script=$(basename "$0")
|
|
version="1.0.1"
|
|
|
|
help() {
|
|
echo
|
|
echo "$script"
|
|
echo
|
|
echo 'Description: Export Docker container content.'
|
|
echo "Syntax: $script [-c|-p|-o|-V|help]"
|
|
echo 'Example: $script -c odoo01 -p /var/lib/odoo/filestore/odoo -o /tmp'
|
|
echo 'options:'
|
|
echo ' -c Name of Docker container.'
|
|
echo " -p Path in container. Defaults to '/'"
|
|
echo " -o Output directory. Defaults to '/var/tmp'"
|
|
echo " -V Show $script version."
|
|
echo " help Show $script manual."
|
|
echo
|
|
}
|
|
|
|
if [[ "$1" == 'help' ]]; then
|
|
help
|
|
exit
|
|
fi
|
|
|
|
path=/
|
|
dir=/var/tmp
|
|
|
|
while getopts ":c: :p: :o: :V" opt; do
|
|
case $opt in
|
|
c) container="$OPTARG"
|
|
;;
|
|
p) path="$OPTARG"
|
|
;;
|
|
o) dir="$OPTARG"
|
|
;;
|
|
V) echo "$script version $version"
|
|
exit 0
|
|
;;
|
|
\?) echo "Invalid option -$OPTARG" >&2
|
|
help
|
|
exit 1;;
|
|
esac
|
|
done
|
|
|
|
[[ -z "$container" ]] && { echo 'Parameter -c|container' ; exit 1; }
|
|
container_id=$(docker ps -f "name=${container}" -q | head -n1)
|
|
[[ -z "$container_id" ]] && { echo "Container id for $container not found." ; exit 1; }
|
|
|
|
echo "Stream content from '$path' path of $container container..."
|
|
docker exec "$container_id" tar -cf - -C "$path" . > "${dir}/${container}.tar"
|
|
|
|
echo "Docker container export has finished: ${dir}/${container}.tar"
|