This repository has been archived on 2025-04-28. You can view files and clone it, but cannot push or open issues or pull requests.
solr-shard-management/solr-docker-copy.sh
2022-05-11 18:51:20 +00:00

33 lines
912 B
Bash
Executable File

#!/bin/bash
. ./setenv.sh
if [[ ! -z "$SOLR_LOCALPATH" ]]; then
SOLR_LOCALPATH=/tmp
fi
ARG_DOCKER_SOURCE=$1
ARG_DOCKER_TARGET=$2
ARG_BACKUP_TIMESTAMP=$3
if [[ ! -z "$ARG_BACKUP_TIMESTAMP" ]]; then
echo "A timestamp of the backup to copy is required"
exit 1;
fi
if [[ ! -z "$ARG_DOCKER_SOURCE" ]]; then
echo "A source Docker container name or ID is required"
exit 1
fi
if [[ ! -z "$ARG_DOCKER_TARGET" ]]; then
echo "A target Docker container name or ID is required"
exit 1
fi
# copy from one node to the other
docker container cp ${ARG_DOCKER_SOURCE}:${SOLR_LOCALPATH}/snapshot.${ARG_BACKUP_TIMESTAMP} /tmp
docker container cp /tmp/snapshot.${ARG_BACKUP_TIMESTAMP} ${ARG_DOCKER_TARGET}:${SOLR_LOCALPATH}
docker container exec --privileged -u root ${ARG_DOCKER_TARGET} chmod -R go+r ${SOLR_LOCALPATH}/snapshot.${ARG_BACKUP_TIMESTAMP}
rm -rf /tmp/snapshot.${ARG_BACKUP_TIMESTAMP}