servercontainers/adminscripts/backup_from_gdrive.sh

13 lines
445 B
Bash
Executable File

#!/bin/bash
mkdir ~/gdrivebackup
rclone copy rootGdrive: ~/gdrivebackup/.
EPOCH=$(date +%s)
tar -cpf ~/backups/gdrivebackup_$EPOCH.tar ~/gdrivebackup;
rm -rf ~/gdrivebackup
BACKUP_COUNT=$(ls -tU ~/backups/gdrivebackup_* | wc -l)
SIZE_DISK=$(df / --output=avail | tail -1) #if less than 100G available
if [[ $BACKUP_COUNT -gt 10 ]] || [[ $SIZE_DISK -lt 100000000 ]]
then rm $(ls -tU ~/backups/gdrivebackup_* | head -1) # delete oldest backup
fi