Created
February 8, 2021 03:23
-
-
Save kainjinez/c50d19ffeba4164b4861edd4bed8d81b to your computer and use it in GitHub Desktop.
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
# PUS EDU Plugin - Backup Server and Upload to Cloud | |
# Version: 2.0 | |
#!/bin/bash | |
SERVER_NAME=$(hostname) | |
TIMESTAMP=$(date +"%F") | |
BACKUP_DIR="/home/backup/$TIMESTAMP" | |
SECONDS=0 | |
size=$(du -sh $BACKUP_DIR | awk '{ print $1}') | |
echo "Bat Dau Backup thu muc $BACKUP_DIR"; | |
/usr/sbin/rclone move $BACKUP_DIR "remote:$SERVER_NAME/$TIMESTAMP" >> /var/log/rclone.log 2>&1 | |
# Clean up | |
rm -rf $BACKUP_DIR | |
/usr/sbin/rclone -q --min-age 6w delete "remote:$SERVER_NAME" #Remove all backups older than 2 week | |
/usr/sbin/rclone -q --min-age 6w rmdirs "remote:$SERVER_NAME" #Remove all empty folders older than 2 week | |
/usr/sbin/rclone cleanup "remote:" #Cleanup Trash | |
echo "Finished"; | |
echo ''; | |
duration=$SECONDS | |
echo "Total $size, $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment