backup-containers/backup/backup.sh
2024-07-03 00:13:58 -07:00

15 lines
348 B
Bash

#!/bin/bash
source /.env
FILENAME="$NAME $(date +%Y-%m-%d\ %H-%M).tgz"
DIRNAME="$(date +%Y\/%m)"
# tar volumes
tar -aczf "/tmp/$FILENAME" -C /volumes .
# ship to host
ssh -i id $NAME@$HOST mkdir -p /home/$NAME/$DIRNAME/
rsync -r -e "ssh -i /id" "/tmp/$FILENAME" $NAME@$HOST:/home/$NAME/$DIRNAME/$FILENAME
# delete backup
rm -rf "/tmp/$FILENAME"