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

April 21st, 2013 by Andrea Matesi 5165 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.

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

April 6th, 2013 by Andrea Matesi 15262 Views

A very interesting Synology feature is the block level synchronization.

This feature allows you to synch only your file changes at the “block level”, between your SRC-NAS and your DST-NAS.

Suffice it to say it is very efficient on your bandwidth!

Example:

Provided you have two equal Synology NASes (I had two DS1511+), and you wish to avail of the Block Level Synchronization feature, let's assume:

  • SRC-NAS is: 192.168.1.200
  • DST-NAS is: 192.168.1.201

Synology NASes are managed through a nice Web-UI, so I'll also assume you got full access to both.

On the SRC-NAS.

Go to Control Panel -> group and add a new group (group).
Go to Control Panel -> user and add a new admin user (usr).
Go to Control Panel -> Shared Folder and create a new shared folder (shared-folder-bck, use default options).

Go to Control Panel -> Network Backup, then make sure “Enable Network Backup service” is ticked, then check “Synology Backup Mode”.

Go to Backup and restore (either from the “arrow” menu or from the search menu - tip: input the first 3 chars and select it).

Create a new “Shared folder Sync” task by clicking the “Create” button and by following the wizard (choose the options you like).

On the DST-NAS.

Go to Control Panel -> group and add a new group (group).
Go to Control Panel -> user and add a new admin user (usr).
Go to Control Panel -> Shared Folder and create a new shared folder (shared-folder-bck, use default options).

Go to Control Panel -> Network Backup, then make sure “Enable Network Backup service” is ticked, then check “Synology Backup Mode” and “Enable Shared Folder Sync Service”.

Go to Backup and restore (either from the “arrow” menu or from the search menu - just input the first 3 chars and select it).

Create a new “Shared folder Sync” task by clicking the “Create” button and by following the wizard (choose the options you like).

Then test by uploading a new file inside your shared folder!

From you computer.

\\SRC-NAS-IP\shared-folder-bck
input user/pwd combo
create a new text file and save it.

You’ll see that the DST-NAS-IP will automatically reflect your changes :)

Posted in System Administration | 1 Comment »