'

Synology-to-Synology Block Level Synchronization - pt.2.

April 21st, 2013 by Andrea Matesi 5106 Views

Part 2 of my Tutorial is going to analyze a slightly more advanced function: a custom weekly backup copy.

BEWARE - This is not supported by Synology, so here you'll be on your own!

Also, since this builds on my previous article, please have a look at it:

Synology-to-Synology Block Level Synchronization - pt.1.

Righto, at this point I assume you got everything setup and synched between your two Synology NAS (as per my previous tutorial).

The only issue I can't but notice is that one (or more) corrupt files From your SRC-NAS could be spread (by the block level synchronization), To the DST-NAS - corrupting BOTH of your copies!

So it’d be wise to create some "working copies" of your block-level synched data (on your DST-NAS).

By following my example, you'll end up with a daily copy (re 1 whole week), of the pr0n you'd like to keep in-synch.

This is possible courtesy of Synology's reliance on a customised Linux distro (which may be further customized by deploying your own scripts, as documented below).

A very basic script.

My very basic script will show you how to run a cron job inside your Synology DST-NAS, which will create a daily backup copy of your synched data (ie. From your SRC-NAS to your DST-NAS).

On your DST-NAS:

- SSH as root to your DST-NAS (Synology uses the same “admin” password - simply type root plus your admin’s password).

mkdir /usr/local/scripts/
vi daily-rsync.sh:
#!/bin/ash
# Insert your comments here...
# Copy "shared-folder-bck" inside "shared-folder-week"

DOW=$(date | cut -d" " -f 1)

rsync -aHvzh /volume1/shared-folder-bck/ /volume1/shared-folder-week/$DOW/

Save and quit.

Schedule your very basic script on cron.

Edit your crontab as follows:

vi /etc/crontab
#minute hour    mday    month   wday    who     command
0       0       *       *       *       root    /usr/sbin/ntpdate -b it.pool.ntp.org
0       23      *       *       *       root    /usr/local/scripts/daily-rsync
0       0      *       *       0       root    rm -rf /volume1/shared-folder-week/*

That would:

- Perform a Daily copy of your synched data.

- (Weekly) Purge the copy of your whole previous week of synched data.

Beware: by so doing, you'll still have one day where data corruption may still happen, but this is an exercise I leave you to solve (feel also free to share your thoughts;-)).

Posted in System Administration | Comments Off on Synology-to-Synology Block Level Synchronization - pt.2.

Comments are closed.