Created
August 25, 2020 19:48
-
-
Save JamesOBenson/ba583202d8e61792b11873342f1d6650 to your computer and use it in GitHub Desktop.
Backup files directly from ceph_mon docker container, download to docker container, then locally, and lastly copy offsite for backup.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sshlogin="username@xx.xx.xx.xx" | |
cephdir=vms | |
array=() | |
while IFS='' read -r line; do array+=("$line"); done < <(docker exec ceph_mon rbd ls -p "$cephdir") | |
for ID in "${array[@]}"; do | |
echo "Do you want to skip this file: $ID" | |
options=("yes" "no") | |
select skipbackup in "${options[@]}" | |
do | |
case $skipbackup in | |
"yes") | |
echo "skipping this file..." | |
break;; | |
"no") | |
echo "exporting $ID..." | |
docker exec ceph_mon rbd export "$cephdir"/"$ID" ~/"$ID".raw | |
echo "copying $ID locally..." | |
docker cp ceph_mon:/root/"$ID".raw /root/"$ID".raw | |
echo "copying $ID to NAS..." | |
scp /root/"$ID".raw "$sshlogin":~ | |
echo "deleting $ID on docker image..." | |
docker exec ceph_mon rm /root/"$ID".raw | |
echo "deleting $ID locally ..." | |
ssh -q "$sshlogin" test -f "~/$ID.raw" && rm /root/"$ID".raw || scp /root/"$ID".raw "$sshlogin":~ | |
break;; | |
esac | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment