change date to backup total folder on remote filesystem

This commit is contained in:
Roger Pàmies Fabra 2022-07-26 12:56:17 +02:00
parent 7cc818be59
commit 0953ca28c9
1 changed files with 4 additions and 1 deletions

View File

@ -11,13 +11,13 @@ ORIGIN_DATA_PATH=$2
REMOTE_SERVER=$3
REMOTE_PATH=$4
LATEST_LINK="latest"
CURRENT_DATE=`date +\%y\%m\%d\%H\%M.\%S`
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
@ -25,6 +25,9 @@ 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
# set current date to sync remote folder
ssh $REMOTE_SERVER "touch -t $CURRENT_DATE $REMOTE_PATH$BACKUP_DIR 2>&1" >> $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