Synology rsync synchronisatie terminal

Synology rsync synchronisatie terminal

Synology rsync synchronisation terminal explains the steps to synchronise two shared folders via the rsync protocol. The rsync commando's are executed in a terminal session that's why SSH must be enabled on the Synology NAS. Be careful running the terminal commands because files and folders can be deleted, running the commands is at your own risk. 

 

Synology rsync synchronisation terminal

Synology rsync synchronisation terminal access

You have to make sure that SSH is enabled on the Synology NAS. This can be done from the control panel under Terminal & SNMP. For Windows you can use PuTTY to connect via SSH.

Terminal command:

ssh <admin user>@server

sudo -i

Turn on rsync on the Synology NAS-servers

To turn on rsync on the Synology NAS open control panel, file services, enable rsync service. Both Synology NAS-servers should have the rsync service running otherwise the Synology rsync synchronisation terminal commands don't run.

Identify both folders for Synology rsync synchronisation

Choose which folder on the source Synology NAS you want to synchronise to the other Synology NAS server which will be the destination. When the folder on the destination doesn't exits it will be created but not seen in the control panel as a shared folder. You can make it a shared folder afterwards and the synchronised data will not be overwritten. It is also possible to create first the shared folder on the destination NAS before the synchronisation. The advantage here is that the folder is created with the correct settings like permissions.

Hyper Backup and the difference with Synology rsync synchronisation terminal commands

With Hyper Backup you can create a rsync copy (single-version). The disadvantage from this way is that a subfolders are created under the destination shared folder and not directly inside the shared destination folder. The rsync job will create a backup folder and is not suitable for this purpose.

Shared Folder Sync and the difference with Synology rsync synchronisation terminal commands

When you have already on the destination, shared folders with identical names as the source shared folders, the folders at destination will be renamed! When the folders don't exists on the destination the will be created. When you already have a shared folder on the destination and the data is quit large, deleting the folder will take more time than to synchronise only the differences. After the creating of the shared folder at the destination you cannot access the files without changing the permissions. Also changing the files/folders at the destination after changing the permissions will not result in synchronising the source folders to the destination, running a full synchronisation does the job.

Synology rsync synchronisation terminal commands

Let me start by saying to be careful how you proceed with the following commands because they will overwrite and delete files and folder!  So test first and check if the command is doing as expected.

Run the following Synology rsync synchronisation terminal commands at your own risk and first test before usage!!!!

Name Source Synology NAS server: server01

Name Destination Synology NAS server: server02

Shared folder on server01: test test

Shared folder on server02: test test

start terminal session on server01 or server02:

Terminal command:

ssh <admin user>@<servername>

sudo -i

command is run from server01 or server02:

Assumed volume1

Purpose: make source shared folder the same on the destination NAS.

Delete files/folders within the destination shared folder to make sure that the destination shared folder is the same as the source shared folder.

Running the Synology rsync synchronisation terminal command

Run the following Synology rsync synchronisation terminal commands at your own risk and first test before usage!!!!

from server 02:

rsync -avhz --delete <admin user>@server01:"'/volume1/test test/'" "/volume1/test test/"

from server 01:

rsync -avhz --delete "/volume1/test test/" <admin user>@server02:"'/volume1/test test/'"

-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)

-v, --verbose               increase verbosity

-h human readable

-z, --compress              compress file data during the transfer

-r, --recursive             recurse into directories

-l, --links                 copy symlinks as symlinks

-p, --perms                 preserve permissions

-t, --times                 preserve modification times

-o, --owner                 preserve owner (super-user only)

-g, --group                 preserve group

     --devices               preserve device files (super-user only)

     --specials              preserve special files

-D                          same as --devices --specials

--delete delete files in the destination.

Synology scp command

Synology scp command

Synology scp command via the terminal explains the steps to secure copy a folder to another NAS folder via the scp command. The scp command is executed in a terminal session that's why SSH must be enabled on the Synology NAS. Be careful running the terminal commands because files and folders can be deleted, running the commands is at your own risk. 

 

Synology scp command

Synology scp command terminal access

You have to make sure that SSH is enabled on the Synology NAS. This can be done from the control panel under Terminal & SNMP. For Windows you can use PuTTY to connect via SSH.

Terminal command:

ssh <admin user>@server

sudo -i

Identify both folders:

Choose which folder on the source Synology NAS you want to copy to the other Synology NAS server which will be the destination. If the destination folder doesn't exists you can create it before the copy.

Synology scp command

Let me start by saying to be careful how you proceed with the following commands because they will overwrite and delete files and folder!  So test first and check if the command is doing as expected.

Run the following scp command at your own risk and first test before usage!!!!

Name Source Synology NAS server: server01

Name Destination Synology NAS server: server02

Shared folder on server01: test test

Shared folder on server02: test test

start terminal session on server02:

Terminal command:

ssh <admin user>@server01

sudo -i

command is run from server01:

Assumed volume1

Purpose: make source shared folder the same on the destination NAS.

Secure copy files/folders within the source shared folder to the destination folder. Also copy hidden files.

Running the Synology scp command

Run the following scp command at your own risk and first test before usage!!!!

cd /volume1

pwd

scp -rp  test\ test/.  <admin user>@server02:"'/volume1/test test/'"

-r      Recursively copy entire directories. Note that scp follows symbolic links encountered in the tree traversal

-p     Preserves modification times, access times, and modes from the original file.

.       Will copy also hidden files.

Synology SMB instelling

Synology SMB instellingen

 

SSH connection:

for example admin@server

sudo -i

vi /etc/samba/smb.conf

Under global section:

server signing=mandatory
client signing=mandatory

min protocol=SMB2
max protocol=SMB3

De SMB connectie met macOS wordt gecontroleerd met het volgende commando in een terminal sessie.

check of er een SMB verbinding is (smbfs);

mount

check welke versie SMB gebruikt wordt (SMB_version);

smbutil statshares -a

De SMB connectie met Windows 10 wordt gecontroleerd met het volgende commando in een terminal sessie.

net use

check welke versie SMB gebruikt wordt (SMB_version);

PowerShell:

Get-SmbConnection

Get-SmbConnection | Select-Object -Property *

 

Synology connectie aanpassen

Synology change connection

Synology change connection shows how to change the connection without a new synchronisation. Sometimes you cannot change the connection because it is grayed out and you have to unlink first and make a new connection.

 

Synology change connection

 

Synology change connection settings Cloud Station ShareSync:

 

1. Use Chrome to login DSM and launch Cloud Station ShareSync to start editing the connection of the task.

2. Enable the Developer Tools:

3. Go to the Console tab:

4. Input the following command and hit enter:

document.querySelector(“.syno-dscc-create-wizard input[name=address]”).disabled = false;

5. Now it’s possible to edit the server address even it’s still greyed out:

 

6. Once it’s done, click on “Apply” to confirm and Cloud Station ShareSync would start connecting to the newly specified server address:

 

 

Synology Hulpprogramma

Synology Hulpprogramma’s

Synology utilities gives a list of applications which are handy to be used with Synology.

Synology Utilities

WinMerge

WinMerge is Open Source and is a tool for comparing folders and files.

For the link to the website click here.

TLPD

TLPD (Too Long Paths Detector) is a tool to tackle the path name too long issue.

For the link to the website click here.

Teracopy

Is a tool for advanced copy of files

For the link to the website click here.

GoodSync

Is a tool for File Backup and File Synchronization

For the link to the website click here.


Need to know more about Diktio Solutions & Synology

click here

Synology Terminal Mount Volume & Map

Synology Terminal Mount Volume & Map

Synology Terminal Mount Volume & Map shows commands you can execute via the terminal to mount volumes or encrypted shared folders. Always contact Synology support first for help and follow their directions and make sure you have a working backup. If you like to try it is on your own risk!

 

Synology Terminal Mount

 

Always contact Synology support first for help and make a working backup first. Use this steps on your own risk!

Synology Terminal Mount after a crashed volume:

after a crashed volume which is not recoverable from the GUI you can try to mount the volume as read-only in a terminal.

Make terminal ssh connection to Synology NAS.

cat /etc/fstab

fdisk -l

cat /proc/mdstat

mdadm --detail /dev/<mdX, check cat /proc/mdstat>

check md not listed. For example md9

use at own risk:

mdadm -A -R /dev/<md not listed> /dev/<disk not crashed> /dev/<disk not crashed>

-A, --assemble Assemble a pre-existing array

-R, --run Attempt to start the array even if fewer drives were given than are needed for a full array. Normally if not all drives are found and --scan is not used, then the array will be assembled but not started. With --run an attempt will be made to start it
anyway.

command should return the message "mdadm: /dev/<md not listed>  has been started with x drives."

lvm vgscan : take note of volume group name

vgchange -a y <volume group name, for example:vg1000>

-a, --activate

The command to mount the volume as read-only in order:

mount -o ro,noload /dev/<volume group name>/lv /volume1

volume group must exists on your system.

the volume should be reachable in the terminal session.

To see the data in DSM using File Station or Windows File Service (SMB)

synospace --map-file -d

synocheckshare

Synology Terminal Mount encrypted map:

Always contact Synology support first for help and make a working backup first. Use this steps on your own risk!

You need the password to decrypt the shared folder.

If you don't have the password but you have the key file, you can run the following command to retrieve the password, I used a Ubuntu Linux system with ecryptfs-utils installed.

printf "%s" "\$1\$5YN01o9y" | ecryptfs-unwrap-passphrase <keyfile.key>

 

Make terminal ssh connection to Synology NAS.

cd /volume<>

ls -al

check your folders, for example  an encrypted folder named encrypt

@encrypt@ and encrypt

If only @encrypt@ exits and not encrypt this could mean the @encrypt@ folder is not mounted on mount point encrypt.

check with ls command the ls

ls -al @encrypt@ and ls-al encrypt

mount

and check it encrypted folder is mounted ( for example):

when it is mounted it will show:

/volume1/@encrypt@ on /volume1/encrypt type ecryptfs (rw,relatime,ecryptfs_fnek_sig=<>,ecryptfs_sig=<>,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_unlink_sigs)

when encrypt is not mounted it will not show this line after the mount command.

to mount the @encrypt@ folder on mount point encrypt.

first check if encrypt folder exists.

if not exits run mkdir encrypt ( this directory wil be deleted after encrypting the folder from the GUI, the folder cannot be removed with the rm command)

to mount:

mount.ecryptfs \@encrypt\@/ encrypt/

Passphrase: <fill in the password used to encrypt the folder, without the password you cannot see your data>

Select cipher: 

 1) aes: blocksize = 16; min keysize = 16; max keysize = 32

 2) blowfish: blocksize = 8; min keysize = 16; max keysize = 56

 3) des3_ede: blocksize = 8; min keysize = 24; max keysize = 24

 4) twofish: blocksize = 16; min keysize = 16; max keysize = 32

 5) cast6: blocksize = 16; min keysize = 16; max keysize = 32

 6) cast5: blocksize = 8; min keysize = 5; max keysize = 16

Selection [aes]: select 1 aes

Select key bytes: 

 1) 16

 2) 32

 3) 24

Selection [16]: 2 (32)

Enable plaintext passthrough (y/n) [n]: n

Enable filename encryption (y/n) [n]: y

WARNING: Based on the contents of [/root/.ecryptfs/sig-cache.txt],

it looks like you have never mounted with this key 

before. This could mean that you have typed your 

passphrase wrong.

Would you like to proceed with the mount (yes/no)? : yes

Would you like to append sig [] to

[/root/.ecryptfs/sig-cache.txt] 

in order to avoid this warning in the future (yes/no)? : yes

Successfully appended new sig to user sig cache file

Mounted eCryptfs

run command, mount and check

/volume1/@encrypt@ on /volume1/encrypt type ecryptfs (rw,relatime,ecryptfs_fnek_sig=<>,ecryptfs_sig=<>,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_unlink_sigs)

cd  /volume1/encrypt

ls -al to check your data

you could use scp to copy your data to another device

To see the data in DSM using File Station or Windows File Service (SMB)

synospace --map-file -d

synocheckshare

 

 

Synology Terminal Commando

Synology Terminal Commando

Synology Terminal Commando laat meerdere commando's zien die uitgevoerd kunnen worden na het maken van een ssh verbinding met de Synology NAS. Ssh moet wel eerst ingeschakeld worden op de Synology NAS om verbinding te kunnen maken.

Synology Terminal Commando

 

 

 

 

 

 

 

start terminal via ssh

ssh user@host

sudo -i

Geef nogmaals het wachtwoord op, hierna kunnen commando's uitgevoerd worden.

Check Network traffic and Bandwidth on Synology NAS.

synogear install

iftop

Synology Terminal commando check open port en programma:

netstat -natpu

-a, --all                display all sockets (default: connected)

-n, --numeric        don't resolve names

-p, --programs      display PID/Program name for sockets

-t                         display only TCP connections

-u.                       display only UDP connections

Synology display activity like pid, processor, memory and

htop

 

Synology Snelheidstest

Synology Snelheidstest

Synology Snelheidstest is een test die uitgevoerd wordt tussen twee Synology NAS-servers. Voor de test wordt gebruik gemaakt van de FTP service op één van de  Synology NAS-servers. Op deze server staat een bestand wat gedownload wordt vanaf de andere server via het Curl commando.

Synology Snelheidstest

Synology Snelheidstest voorbereiding:

turn on ssh on the Synology NAS, Control Panel, Terminal & SNMP, enable SSH service.

root Login using ssh:

ssh user@servernameoripaddress

sudo -i

To download a file from a ftp server anonymous (example):

curl -O ftp://ftp.xs4all.nl/pub/test/1gb.bin

To download a file from a Synology ftp server with authentication(example):

curl  -O ftp://<servername>/<shared folder>/<name file> --user '<Synology User>:<password>'

or

curl -n --netrc-file <file name, or path to file name>  -O ftp://<servername>/<shared folder>/<name file>

 -n, --netrc   Must read .netrc for user name and password

     --netrc-file FILE  Specify FILE for netrc

file name contents:

machine <name Synology NAS-server>

login <ftp user on Synology NAS>

password <password ftp user on Synology NAS>

To upload a file to a ftp server (example):

make sure you have a 1GB file. Not in the root folder or delete afterwards.  

curl -T 1gb.bin ftp://speedtest.tele2.net/upload/

Speed in MByte/s(MB/s or kByte/s)
In case M multiple by 10 for megabit per second(Mbps)
In case k divide by 1000 for MByte/s(MB/s)
In case k divide by 100 for megabit per second(Mbps)

schedule download speed task:

create owner executable file with following contents:

cd /volume1/homes/user/
curl -O ftp://ftp.xs4all.nl/pub/test/1gb.bin
rm /volume1/homes/admin/1gb.bin

Control panel, Task Scheduler, create task, run command

/volume1/homes/user/<name file>.sh

Synology MailPlus Installatie & Configuratie

Synology MailPlus Installatie & Configuratie

Synology MailPlus Installatie & Configuratie, laat de installatie en diversen configuratie instellingen zien. Het is goed mogelijk om Synology MailPlus ook te gebruiken indien er geen vast publiek ip adres voorhanden is. Het dient aanbeveling om gebruik te maken van een Mail-relay oplossing.

Synology MailPlus Installatie & Configuratie

Synology MailPlus Installatie & Configuratie voorbereiding:

Ruimte:

Voor de installatie is het verstandig goed na te denken over de benodigde ruimte rekening houdend met het aantal e-mail gebruikers. In het geval van 20 gebruikers en elk ruimte van 50 GB is de benodigde ruimte dus minimaal 1000 GB. Kan het aantal gebruikers toenemen in de toekomst en ja hoeveel groei kan dan verwacht worden. Stel de verwachting is elk jaar 2 extra gebruikers met elk 50 GB dan wordt de minimale ruimte op basis van 5 jaren dan 1500 GB.  Een apart uitbreidbaar volume voor MailPlus is dan ook aan te raden met wellicht een eigen storage pool. In het geval dat gebruik gemaakt wordt van een Mailplus high-availability (HA)-cluster heb je twee keer dezelfde ruimte nodig.

Btrfs:

Door gebruik te maken van btrfs en snapshot technology kan van de gedeelde map een snapshot gemaakt worden. Hierdoor wordt er een back-up gemaakt van de e-mails die weer gebruikt kan worden in geval van een calamiteit.

Mail Cluster:

Door bij de Synology Mailplus Installatie & Configuratie gebruik te maken van een high-availability (HA)-cluster zal bij een calamiteit op een server of wanneer hardware vervangen wordt de andere server de volledige werklast overnemen. Een Mailplus high-availability (HA)-cluster is wat anders dan Synology High availability (SHA) waar gebruik wordt gemaakt van meestal twee identieke Synology NAS-Servers waarvan 1 actieve server en de andere server passief. Bij een Mailplus high-availability (HA)-cluster zijn beide servers actief maar is op 1 server Mailplus draaiend, de primaire server. Het wordt aanbevolen om gebruik te maken van een Mailplus high-availability (HA)-cluster in het geval dat de beschikbaarheid belangrijk is.

Hardware:

Houdt bij de Synology Mailplus Installatie & Configuratie keuze rekening met de hardware. Mailplus gebruikt veel CPU kracht en veel geheugen. Door gebruik te maken van de security settings van Mailplus zoals anti-spam engine neemt de gevraagde CPU rekenkracht en geheugen toe.

 

 

 

Synology UPS NUT

Synology UPS NUT

Synology UPS NUT (network UPS Tools), door aan een Synology NAS een UPS te koppelen wordt voorkomen dat er dataverlies optreedt of hardware stuk gaat bij een stroomstoring. Daarnaast kunnen ook andere apparaten een seintje krijgen om uitgezet te worden bij een stroomstoring. Synology has implemented NUT: http://networkupstools.org

Synology UPS NUT

De gebruikte configuratie voor Synology UPS NUT:

Synology NAS connected via Dataport to APC Back-UPS ES 700.

Synology DSM 6.1 en 6.2

The configuration files on the Synology NAS  are found here:

/usr/syno/etc/ups, which you can access via a terminal

upsd.conf

upsd.users

ups.conf

After changing the file you can reload the configuration:

upsd -c reload

Setting via the GUI, control panel, Hardware & Power, UPS:

Under general you can configure:

restart automatically after a power failure

To get UPS status information from another device and user:

you have to be in the upsd.users file and be in the list of permitted disk station devices, (control panel, Hardware & Power, UPS)

run the following command to check UPS information and status from another device:

upsc <name ups, see NAS /usr/syno/etc/ups/ups.conf>@<ip address NAS>

for example upsc ups@192.168.1.10

To change a value for example for testing:

upsrw -s battery.charge.low=<new value> -u <user, defined in upsd.conf NAS> -p <password user in upsd.conf> <name ups, see NAS /usr/syno/etc/ups/ups.conf>@<ip address NAS>

To install a nut client on a Mac:

I used Fink Project;  http://www.finkproject.org to install Fink Project.

To install nut on your Mac:

fink install nut

The configuration files:

/sw/etc/nut

upsmon.conf:

RUN_AS_USER root

MONITOR <name ups, see synology ups.conf>@<ip address> 1 <user, see synology upsd.users> <password, see synology upsd.users> slave

MINSUPPLIES 1

SHUTDOWNCMD "/sbin/shutdown -u -h +0"

NOTIFYCMD /sw/sbin/upssched

POLLFREQ 5

POLLFREQALERT 5

HOSTSYNC 15

DEADTIME 15

POWERDOWNFLAG /etc/killpower

NOTIFYFLAG ONLINE EXEC
NOTIFYFLAG ONBATT SYSLOG+EXEC
NOTIFYFLAG LOWBATT EXEC
NOTIFYFLAG NOCOMM EXEC
NOTIFYFLAG COMMBAD IGNORE
NOTIFYFLAG COMMOK IGNORE
NOTIFYFLAG SHUTDOWN IGNORE
NOTIFYFLAG FSD EXEC
NOTIFYFLAG NOPARENT SYSLOG

RBWARNTIME 43200

NOCOMMWARNTIME 300

FINALDELAY 5

upssched.conf

CMDSCRIPT /sw/bin/upssched-cmd

PIPEFN /sw/var/run/ups/upssched/upssched.pipe

LOCKFN /sw/var/run/ups/upssched/upssched.lock

AT ONBATT <name ups, see synology ups.conf>@<ip address> EXECUTE on-battery

/sw/bin/upssched-cmd:

case $1 in
upsgone)
logger -t upssched-cmd "The UPS has been gone for awhile"
;;

on-battery)
osascript -e 'tell app "System Events" to display dialog "Power failure. Save your work" giving up after 20 buttons {"OK"} default button 1 with icon caution'
;;

*)
logger -t upssched-cmd "Unrecognized command: $1"
;;
esac

To start upsmon manually: 

sudo upsmon -D (/sw/sbin/upsmon)

-D       Raise the debugging level. upsmon will run in the foreground and

prints information on stdout about the monitoring process. Use this

multiple times for more details.

upsmon -c stop ( stop monitoring and exit)

upsmon -c reload ( reread upsmon.conf) 

To start upsmon automatically on a macOS Sierra :

/Library/LaunchDaemons

-rw-r--r--   1 root  wheel   org.networkupstools.upsmon.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.networkupstools.upsmon</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/sw/sbin/upsmon</string>
<string>-D</string> <!-- "-D" keeps upsmon from going into the background -->
</array>
<key>KeepAlive</key>
<true/>
<key>SuccessfulExit</key>
<false/> <!-- Do not respawn at shutdown time -->
</dict>
</plist>

To load manually:

sudo launchctl load /Library/LaunchDaemons/org.networkupstools.upsmon.plist

system.log:

com.apple.xpc.launchd[1] (org.networkupstools.upsmon): Unknown key for Boolean: SuccessfulExit
com.apple.xpc.launchd[1] (org.networkupstools.upsmon): This service is defined to be constantly running and is inherently inefficient.

To see if it is running:

sudo launchctl list|fgrep -v com.app

PID     Status  Label

<PID> 0 org.networkupstools.upsmon

ps -ef |grep upsmon

0 88 1 0 9:52AM 0:00.01 /sw/sbin/upsmon -D
0 167 88 0 9:52AM  0:00.50 /sw/sbin/upsmon -D

To install a nut client on Linux CentOS 6.9 :

Download the binary package of Feodora EPEL6, nut-client

Install on Linux machine with rpm command:

for example: rpm -ivh nut-client-2.6.5-2.el6.x86_64.rpm

make a user nutmon and at to group nut:

adduser nutmon

passwd nutmon

usermod -a -G nut nutmon

groups nut

Config files:

/etc/ups/

check nut group read rights upsmon.conf

upsmon.conf:

RUN_AS_USER nutmon

MONITOR <name ups, see synology ups.conf>@<ip address> 1 <user, see synology upsd.users> <password, see synology upsd.users> slave

MINSUPPLIES 1

SHUTDOWNCMD "/sbin/shutdown -h +0"

POLLFREQ 5

POLLFREQALERT 5

HOSTSYNC 15

DEADTIME 15

POWERDOWNFLAG /etc/killpower

RBWARNTIME 43200

NOCOMMWARNTIME 300

FINALDELAY 5

To run upsmon at startup:

chkconfig --list ups

chkconfig ups on

to check upsmon running:

service ups status

ps -ef |grep upsmon:

root          2271     1    0 Jul08 ?          00:00:00 /usr/sbin/upsmon

nutmon    2273  2271  0 Jul08 ?          00:00:09 /usr/sbin/upsmon

To start en stop upsmon:

service ups start

service ups stop

 

Heeft u hulp nodig. Klik hier voor contact met Diktio Solutions.

1 2 3 4