Synology rsync synchronisation terminal

Synology rsync synchronisation 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 server02:

Terminal command:

ssh <admin user>@server02

sudo -i

command is run from 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

rsync -avhzr --delete <admin user>@server02:"'/volume1/test test/'" "/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

Do you want Diktio Solutions to help you. Click Here to contact Diktio Solutions.

Synology Parity Consistency Check

Synology Parity Consistency Check

Synology Parity Consistency Check to control and check with terminal commands the process

Synology parity consistency check terminal commands. How to see the status of the check and control it for example to let it run faster. Also to see where logging takes places.

Running this commands are at your own risk!  

Synology Parity Consistency Check

start ssh session with Synology NAS.

as root:

To check the status of the running parity consistency check:

cat /proc/mdstat

You can also see the speed.  speed=

Showing the running speed:

cd /sys/block/md<X>/md

Where X is your volume, md0 and md1 are system partitions. So md2 would be the first volume

cat sync_speed will show the running speed

To control speed:

cd /sys/block/md<X>/md :

Where X is your volume, md0 and md1 are system partitions. So md2 would be the first volume

cat sync_speed_min

cat sync_speed_max

By changing this values you can control the speed.

echo <value> >sync_speed_max

The standard value sync_speed_max is high so there is no limit.  By lowering this value you can max the speed and slow down the process.

The standard value sync_speed_min is set low By making this value higher you can try to speed up the process. Just check the current speed and try to make this setting higher and check what happens.

Start/Stop and Pause the parity check

cd /sys/block/md<X>/md :

Where X is your volume, md0 and md1 are system partitions. So md2 would be the first volume

Start:

echo check > /sys/block/mdX/md/sync_action

Pause:

There is no actual pause, since you will still fall back a little bit or resume from the beginning if you reboot the unit. But below is the closest one.

#echo idle > /sys/block/mdX/md/sync_action

Stop:

#echo frozen > /sys/block/mdX/md/sync_action

You will need to replace mdX with your volume. For example, md2, md3... ( md0, md1 are system partitions. )

Where logging takes place? 

/var/log/kern.log

To change debug setting:

cd /sys/block/md<X>/md :

Where X is your volume, md0 and md1 are system partitions. So md2 would be the first volume

echo 1 > sync_debug

tail -f /var/log/kern.log will show the last messages

Messages like this to watch for:

md: data-check of RAID array md2

md: md2: data-check stop due to MD_RECOVERY_INTR set.

md: md_do_sync() got signal ... exiting

Do you want Diktio Solutions to help you. Click Here to contact Diktio Solutions.

Synology File System Check

Synology File System Check

How to run a Synology File System Check on a ext4 file system?

Synology File System Check

DSM used:  DSM 6.2

When checking the log files on a ext4 file system under /var/log I discovered the log file fsck. It appears that every time the system is started the following command is run for Synology File System Check:  /sbin/e2fsck -pvf. From the GUI on my Synology NAS it is not possible to start a Synology File System Check on a ext4 file system.

-p Automatic repair (no questions)

-n Open the filesystem read-only, and assume an answer of 'no' to all questions. Allows e2fsck to be used non-interactively. This option may not be specified at the same time as the -p or -y options.

-v Be verbose

-f Force checking even if filesystem is marked clean

How to run the Synology File System Check on a ext4 manually?

Running this commands are at your own risk. Always make sure you have a good backup as there are risks off data loss.

turn on telnet and don't forget to turn it off again. It is a security issue, passwords go unencrypted over the line. In control panel under Terminal & SNMP you can turn telnet on. You need a telnet program on your computer to connect to the Synology NAS. Don't use SSH because when running the below commands you will loose connection.

df -h and search for volume needed. For example volume1: /dev/vg1000/lv

syno_poweroff_task -d or umount /volume1, if this doesn't work try umount /volume1 -f -k (-k is for killing processes accessing the file)

(syno_poweroff_task) -d debug mode. This command is for killing all processes.

vgchange -ay

-a (--available) for activate or deactivate -y|--yes ]

commands to check the file system:

e2fsck -nvf -C 0 /dev/vg1000/lv (-n option see above)

fsck.ext4 -pvf -C 0 /dev/vg1000/lv or e2fsck -pvf -C 0 /dev/vg1000/lv (-p option see above)

-C 0

-C fdThis option causes e2fsck to write completion information to the specified file descriptor so that the progress of the filesystem check can be monitored. This option is typically used by programs which are running e2fsck. If the file descriptor number is negative, then absolute value of the file descriptor will be used, and the progress information will be suppressed initially. It can later be enabled by sending the e2fsck process a SIGUSR1 signal. If the file descriptor specified is 0, e2fsck will print a completion bar as it goes about its business. This requires that e2fsck is running on a video console or terminal.

After completion run:  reboot

Do you want Diktio Solutions to help you. Click Here to contact Diktio Solutions.

Synology SMB connection with shared folder

Synology SMB Connections

Synology NAS DSM 6.1 with Active Directory (AD) installed on the NAS. Users in AD and Synology NAS users. On the NAS is SMB v1 disabled 

Connect from Ubuntu 16.04 LTS (Latest Stable Version) Gnome desktop 

from the terminal: 

as root:

sudo su -

mount -t cifs //<ip address or DNS name Synology NAS>/<Share> /mnt (or other mount point) -o username=<AD user or NAS user>,vers=<2.1 or 3.0> 

To start within Gnome GUI from terminal:

as root:

nautilus 

or as user: 

sudo mount -t cifs //<ip address or DNS name Synology NAS>/<Share> /mnt (or other mount point) -o username=<AD user or NAS user>,vers=<2.1 or 3.0> 

To start within Gnome GUI from terminal:

sudo nautilus

Connect from Centos 7

from the terminal: 

as root:

sudo su - or su - 

mount -t cifs //<ip address or DNS name Synology NAS>/share -o,user=<AD user or NAS user,domain=<AD netbios domain or other name for NAS users>,vers=<2.1 or 3.0> /mnt (or other mount point)

To start within Gnome GUI from terminal:

as root:

nautilus 

or as user: 

sudo mount -t cifs //<ip address or DNS name Synology NAS>/share -o,user=<AD user or NAS user,domain=<AD netbios domain or other name for NAS users>,vers=<2.1 or 3.0> /mnt (or other mount point)

To start within Gnome GUI from terminal:

sudo nautilus

Synology mount volume as read-only

Always contact Synology support first for help. If you like to try on your own risk: 

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 show S.M.A.R.T report

smartctl --scan

smartctl -a -d sat -T permissive /dev/sda

/dev/sda is the drive

-aPrints all SMART information about the disk.

-d satSpecifies device type. “Sat” is SCSI to ATA Translation (SAT) that is required with Synology.

 -T permissiveDefines tolerance type. “Permissive” tells to ignore failure(s) of mandatory SMART commands and is required with Synology.
 
The commando also shows Hardware disk information:
 
Model Family:     

Device Model:     

Serial Number:   

LU WWN Device Id:

Firmware Version: 80.00A80

User Capacity:    

Sector Sizes:     

Device is:       

ATA Version is:   

SATA Version is:  

Local Time is:    

SMART support is: 

SMART support is: 

 

To run a short S.M.A.R.T test: 

smartctl -d sat -t short /dev/sda

Synology DSM 6 (terminal) service control

Webuserinterface, Synology recommended:

Control Panel, Task Scheduler, Create Scheduled Task, Stop/Start Service 

Terminal command:

ssh admin@server

sudo -i

synoservicecfg --list

synoservicecfg --hard-stop <service>

synoservicecfg -stop <service>

synoservicecfg --hard-start <service>

synoservicecfg -start <service>

synoservice –status

synoservice –restart <service>

synoservicectl –restart <service>

Apache webserver:

stop pkg-apache22

start pkg-apache22

reload pkg-apache22


restart DSM Webapplication:

restart synoscgi


 

Monitor your Apache webserver running on your Synology DSM

DSM 5:

Login as root via a terminal session on your Synology NAS.

vi /etc/httpd/conf/httpd.conf-user

add the following lines and fill allow from:

#Apache server status
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from <fill in the ip address of your server running your Anturis agent>
</Location>

#Apache server status
#To obtain a full report with current status information
ExtendedStatus On

Restart httpd-user daemon:

synoservicectl –restart httpd-user

Within Anturis fill in the monitoring settings:

Apache server connection:

Apache statistics web-page URL (requires mod_status): <servername/server-status>

You can now monitor your Apache webserver running on your Synology NAS.

 

DSM 6:

Login as admin via a terminal session on your Synology NAS.

sudo -i

create file for example status.conf under /usr/local/etc/httpd/sites-enabled/

#Apache server status
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from <fill in the ip address of your server running your Anturis agent>
</Location>

#Apache server status
#To obtain a full report with current status information
ExtendedStatus On

Reload Apache server:

reload pkg-apache22