Category : Synology

How to Setup Auto Backup on Mac using RSYNC

Update your Rsync on mac:
First install Homebrew on your mac,

then
brew tap homebrew/dupes
brew install rsync

edit /private/etc/paths
and put /usr/local/bin ahead of /usr/bin and then restart Terminal šŸ™‚

rsync -va –delete ~/Folder1/ ~/Folder2/

#!/bin/sh
echo BEGIN `date` >> /var/log/backup.log
/usr/bin/caffeinate -s /usr/bin/rsync -aH /Users [email protected]: >> /var/log/backup.log
echo END `date` >> /var/log/backup.log

http://www.bananica.com/Geek-Stuff/Synchronize-two-folders-on-a-Mac-with-Rsync/
http://www.practicallyefficient.com/2011/03/18/rsync-automator.html

Best Script

 

The options I use:

OPTIONS=”-av –no-p –no-g –chmod=ugo=rwX –delete –force”

I have to use –no-p and –no-g, so the folder permissions will be ignored. Ā  and –chmod=ugo=rwX will ensure that all non-masked bits get enabled.

 

SSH to a specific port:

ssh -p 22 [email protected]

SSH in debug mode:

ssh -v [email protected]

Rsync with non-standard SSH Port

rsync -arvz -e ‘ssh -p <port-number>’ –progress –delete [email protected]:/path/to/remote/folder /path/to/local/folder

How to remove folders with a certain name

find . -name folder_name -exec rm -rf {} \;


Backup My Website to Synology via LFTP

There is no FTP in Synology, so I have to use LFTP

Here is my backup.sh

#!/bin/bash -vx
lftp -u username,password ftp.xxx.com<<END_SCRIPT
mirror -c -e –parallel=10 /remote_address /destiny_address
exit
END_SCRIPT

 

If you see “lftp –> Fatal error: Certificate verification: Not trusted” , you can follow this link or the steps below to fix it:

  1. Create the .lftp directory with the command : mkdir /root/.lftp
  2. Create and edit the rc file with the command : vi /root/.lftp/rc
  3. Press ā€˜iā€™ for edit mode
  4. Add the line : set ssl:verify-certificate no
  5. Exit edit mode by pressing Escape (twice)
  6. Close and save the file by pressing Z (capital z) twice)

 

After that I use Synology Task Scheduler to backup my website regularly,

backup.sh | tee -a logfile.text