Page 2 of 2

Re: backup every 12 hours on qnap ftp

Posted: Tuesday 27 March 2018 5:52
by Egregius
This is my current backup script:

Code: Select all

#!/bin/bash
NOW=$(date +"%Y-%m-%d")
RUNLOG=/Users/guy/BackupLogs/$NOW-nas.txt
EXCLUDED=/Users/guy/OneDrive/Backup/excludedfiles.txt

NAME="OneDrive2NAS"
echo  ------------------- START $NAME -- $(date +"%Y-%m-%d %H:%M:%S") | tee -a $RUNLOG
rsync -aP --exclude-from "/Volumes/home/backup/excludedfiles.txt" --stats -e "ssh -i /Users/guy/.ssh/id_rsa -p 1598" --delete-after --link-dest="../__prev/" "/Users/guy/OneDrive/" "[email protected]:/volume1/homes/guy/OneDrive/$NOW" | tee -a $RUNLOG
ssh [email protected] "rm -f /volume1/homes/guy/OneDrive/__prev; ln -s /volume1/homes/guy/OneDrive/$NOW /volume1/homes/guy/OneDrive/__prev;"
echo  ------------------- END  $NAME -- $(date +"%Y-%m-%d %H:%M:%S") | tee -a $RUNLOG
Procedure is that a backup is made to a folder $NOW (datestamp YYYYMMDD), after the backup a symlink is created with the name __prev. That symlink is then used as a base for the new backup resulting in a version for every day the backup has run. Each version only holds the changed files, all the rest are pure symlinks occupying almost no space.