Scripts to do backups of nextcloud data, database and nextcloud files
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nextcloud-backups/weekly_backups.sh

31 lines
1.1 KiB

#!/bin/bash
PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
GOTIFY_TOKEN="token"
GOTIFY_MESSAGE="Backup task init: **"`date +"%d/%m/%Y %H:%M:%S"`"** \r"
LOG_FILE="hostname_"`date +"%d-%m-%Y"`".txt"
PATH_LOCAL_BACKUPS="/path/to/temporal/backups/"
PATH_ORIGIN_DATA="/path/to/nextcloud/data/"
REMOTE_SERVER="remote.example.com"
REMOTE_PATH="/path/to/remote/store/backups/"
mkdir -p $PATH_LOCAL_BACKUPS
touch $LOG_FILE
sh ~/backup_db.sh "$LOG_FILE" "$PATH_LOCAL_BACKUPS" "$REMOTE_SERVER" "$REMOTE_PATH"
sh ~/backup_dir.sh "$LOG_FILE" "$PATH_LOCAL_BACKUPS" "$REMOTE_SERVER" "$REMOTE_PATH"
sh ~/backup_total.sh "$LOG_FILE" "$PATH_ORIGIN_DATA" "$REMOTE_SERVER" "$REMOTE_PATH"
sh ~/backup_clean.sh "$LOG_FILE" "$REMOTE_SERVER" "$REMOTE_PATH"
# send log to logs public archive
LOG_URL=$(sh ~/logger.sh "$LOG_FILE")
# delete local log
rm $LOG_FILE
GOTIFY_MESSAGE="${GOTIFY_MESSAGE} Backup task end: **"`date +"%d/%m/%Y %H:%M:%S"`"** \r"
GOTIFY_MESSAGE="${GOTIFY_MESSAGE} [LogFile]($LOG_URL)"
# send gotify notification
sh ~/gotifypush.sh "NC Total Backup" "$GOTIFY_MESSAGE" 5 "$GOTIFY_TOKEN" "$LOG_URL"