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/backup_total.sh

34 lines
986 B

#!/bin/bash
PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
#Use backup_inc.sh <logfile> <origin_data_path> <remote_server> <remote_path>
LOG_FILE=$1
BACKUP_DIR="nextcloud-datatotal_"`date +\%Y\%m\%d`"/"
EXCLUDE_FILE="file-list.txt"
ORIGIN_DATA_PATH=$2
REMOTE_SERVER=$3
REMOTE_PATH=$4
LATEST_LINK="latest"
touch $EXCLUDE_FILE
cat > $EXCLUDE_FILE <<EOF
files_trashbin
nextcloud.log
updater.log
EOF
echo "\n[NEW BACKUP TASK] Backup cloud all files (total)\n" >> $LOG_FILE
# rsync of new files last day into nextcloud every day (incremental)
rsync -AaxzvPh $ORIGIN_DATA_PATH --exclude-from=$EXCLUDE_FILE "$REMOTE_SERVER:$REMOTE_PATH$BACKUP_DIR" >> $LOG_FILE
# replace latest
ssh $REMOTE_SERVER "rm -rf $REMOTE_PATH$LATEST_LINK && ln -s $REMOTE_PATH$BACKUP_DIR $REMOTE_PATH$LATEST_LINK 2>&1" >> $LOG_FILE
rm $EXCLUDE_FILE
echo "\n[DONE BACKUPS] handycat total backup completed!\n" >> $LOG_FILE
echo "########################################################" >> $LOG_FILE