homelab/scripts/backupvpsdocker
2024-09-09 22:37:51 +10:00

31 lines
627 B
Bash

#!/bin/bash
#
#
# Backup vps02 docker data
#Stop all containers
docker stop $(docker ps -a -q)
date=$(date +%F)
cd /data
for dir in */; do
dir=${dir%*/}
backupfile="$dir-$date.tar.gz"
#echo "backup $dir"
tar -zcf /tmp/$backupfile $dir
if [ $dir == "vaultwarden" ]; then
#echo "rclone vaultwarden"
rclone copy /tmp/$backupfile BitwardenBackup:BitwardenBackup
else
#echo "scp $backupfile"
#scp /tmp/$backupfile mmckinnon@truenas.comprofix.xyz:/mnt/datapool/data/backup/docker/
fi
rm /tmp/$backupfile
done
#Start all containers
docker start $(docker ps -a -q)