2019-10-13 14:07:14 +00:00
|
|
|
#! /bin/bash
|
2021-02-23 11:58:09 +00:00
|
|
|
|
2023-06-23 13:10:17 +00:00
|
|
|
set +e
|
|
|
|
|
2021-02-23 11:58:09 +00:00
|
|
|
if [[ `nmcli -t -f GENERAL.METERED dev show | grep "METERED:yes"` ]]; then
|
|
|
|
echo Backup does not work on metered connections
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-02-20 17:55:12 +00:00
|
|
|
if [[ -z $CONTABO_BACKUP_PATH ]]; then
|
|
|
|
echo CONTABO_BACKUP_PATH environment not set
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-10-13 14:07:14 +00:00
|
|
|
sleep 60
|
2022-01-22 22:14:01 +00:00
|
|
|
|
2023-12-01 22:00:54 +00:00
|
|
|
function ntfy() {
|
|
|
|
/home/bruno/Apps/linuxShortcuts/ntfy.sh --title Backup $1
|
|
|
|
}
|
|
|
|
|
2023-06-23 13:10:17 +00:00
|
|
|
OXO_PATH="/home/bruno/Backups/OXOwebsite/"
|
|
|
|
|
2022-01-22 22:14:01 +00:00
|
|
|
# Backup Contabo
|
2023-06-23 13:10:17 +00:00
|
|
|
echo "Backuping Contabo..."
|
2023-06-28 14:32:30 +00:00
|
|
|
ntfy "Starting Contabo..."
|
2022-02-20 22:03:43 +00:00
|
|
|
/bin/rsync --archive --backup --exclude "files/nextcloud*" --rsh=ssh backupContabo:/home/bruno/backups/* $CONTABO_BACKUP_PATH
|
2019-10-13 14:07:14 +00:00
|
|
|
|
2022-02-02 00:45:08 +00:00
|
|
|
# Backup Gitea
|
2023-06-23 13:10:17 +00:00
|
|
|
echo "Backuping Gitea..."
|
2023-06-28 14:32:30 +00:00
|
|
|
ntfy "Starting GoogleMicro..."
|
2023-06-23 13:10:17 +00:00
|
|
|
/bin/rsync --archive --backup --rsh=ssh bkpgitea:/home/brunofontes/ttt/ /home/bruno/Backups/gitea/
|
2022-02-20 22:03:43 +00:00
|
|
|
|
|
|
|
# Backup OXO Files
|
2023-06-23 13:10:17 +00:00
|
|
|
echo "Backuping OXO Files..."
|
|
|
|
/bin/rsync --archive --backup --exclude='uploads/cf7-uploads-custom/' --rsh=ssh oxo:~/public_html $OXO_PATH
|
|
|
|
|
|
|
|
DATE=$(date '+%Y-%m-%d')
|
|
|
|
|
|
|
|
echo "Borg(ing) OXO Files..."
|
|
|
|
ionice -c 3 nice -n 19 borg create --compression auto,zstd,9 --exclude-from="${OXO_PATH}.exclude" "${OXO_PATH}borg::${DATE}_Files" "${OXO_PATH}public_html/"
|
|
|
|
|
|
|
|
echo "Deleting already backuped OXO Files..."
|
|
|
|
rm -rf "${OXO_PATH}public_html/"
|
2022-02-20 22:03:43 +00:00
|
|
|
|
|
|
|
# Backup OXO DB
|
2023-06-23 13:10:17 +00:00
|
|
|
echo "Backuping OXO DBs..."
|
2022-02-20 22:03:43 +00:00
|
|
|
ssh oxo ./backupDB.sh
|
2023-06-23 13:10:17 +00:00
|
|
|
/bin/rsync --archive --backup --compress --rsh=ssh oxo:~/db/* $OXO_PATH
|
2022-02-20 22:03:43 +00:00
|
|
|
ssh oxo rm ./db/*
|
2023-06-23 13:10:17 +00:00
|
|
|
ionice -c 3 nice -n 19 borg create --compression auto,zstd,9 --exclude-from="${OXO_PATH}.exclude" "${OXO_PATH}borg::${DATE}_DBs" $OXO_PATH
|
|
|
|
rm -f "${OXO_PATH}*.gz"
|
2022-02-02 00:45:08 +00:00
|
|
|
|
2019-10-13 14:07:14 +00:00
|
|
|
# Delete old backups
|
2023-06-23 13:10:17 +00:00
|
|
|
echo "Deleting old backup files..."
|
2021-02-20 17:55:12 +00:00
|
|
|
find $CONTABO_BACKUP_PATH/db -type f -name "*.sql.gz" -mtime +15 -delete
|
|
|
|
find $CONTABO_BACKUP_PATH/keys -type f -name "*.*" -mtime +15 -delete
|
|
|
|
find $CONTABO_BACKUP_PATH/files -type f -name "*.*" -mtime +35 -delete
|
|
|
|
find $CONTABO_BACKUP_PATH/mail -type f -name "*.*" -mtime +20 -delete
|
|
|
|
find $CONTABO_BACKUP_PATH/ -type f -name "*.*" -mtime +120 -delete
|
2022-01-22 22:14:01 +00:00
|
|
|
|
2023-06-23 13:10:17 +00:00
|
|
|
find /home/bruno/Backups/gitea/ -type f -name "*.zip" -mtime +15 -delete
|
2023-06-28 14:32:30 +00:00
|
|
|
ntfy "Websites Backup Finished"
|