I recently purchased a Synology DS1511+ to act as a NAS (network attached storage) for my home network. The 5-drive, Linux powered device is beautiful – small, sleek and quiet. What sold me was the amazing web-based configuration interface they provide, and the ability to access the device remotely via the web or from mobile apps Synology provides in the iTunes App Store and Android Market.
After setting it up with a couple 2TB and 3TB drives, I wanted to use the device to backup documents from several Windows computers I manage (my own, my wife’s netbook and my parents’ computers thousands of miles away). Local network backup is pretty easy – you can use the Synology Data Replicator to backup Windows hosts to your Synology on your local network. However, it seemed pretty slow to me, and doesn’t use the highly-optimized rsync protocol for backing up files. Since I was previously using rsync over SSH to a Linux server I run at home, I figured since the Synology was Linux-based, it should be able to do the same.
All it takes is a few updates to the Synology server, and a few scripts on the Windows computers you want to backup to make this work for both computers on your home network as well as any external computers you want to backup, as long as they know the address of the remote server. You can use a dynamic-IP service such as TZO.com or DynDNS.org so your remote Windows clients know how to contact your home Synology.
Once I got it all working, I figured the process and scripts I created could be used by others with a Synology NAS (or any server or NAS running Linux). I’ve created a GitHub repository with the scripts and instructions so you can setup your own secure backup for local and remote Windows computers:
https://github.com/nicjansma/synology-windows-ssh-rsync-backup
Features
- Uses rsync over ssh to securely backup your Windows hosts to a Synology NAS.
- Each Windows host gets a unique SSH private/public key that can be revoked at any time on the server.
- The server limits the SSH private/public keys so they can only run rsync, and can’t be used to log into the server.
- The server also limits the SSH private/public keys to a valid path prefix, so rsync can’t destroy other parts of the file system.
- Windows hosts can backup to the Synology NAS if they’re on the local network or on a remote network, as long as the outside IP/port are known.
NOTE: The backups are performed via the Synology root user’s credentials, to simplify permissions. The SSH keys are only valid for rsync, and are limited to the path prefix you specify. You could change the scripts to backup as another user if you want (config.csv).
Synology NAS Setup
- Enable SSH on your Synology NAS if you haven’t already. Go to Control Panel – Terminal, and check “Enable SSH service”.
- Log into your Synology via SSH.
- Create a /root/.ssh directory if it doesn’t already exist
mkdir /root/.ssh chmod 700 /root/.ssh
- Upload server/validate-rsync.sh to your /root/.ssh/validate-rsync.sh. Then chmod it so it can be run:
chmod 755 /root/.ssh/validate-rsync.sh
- Create an authorized_keys file for later use:
touch /root/.ssh/authorized_keys chmod 600 /root/.ssh/authorized_keys
- Ensure private/public key logins are enabled in /etc/ssh/sshd_config.
vi /etc/ssh/sshd_config
You want to ensure the following lines are uncommented:
PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys
- You should reboot your Synology to ensure the settings are applied:
reboot
- Setup a share on your Synology NAS for backups (eg, ‘backup’).
Client Package Preparation
Before you backup any clients, you will need to make a couple changes to the files in the client/ directory.
- First, you’ll need a few binaries (rsync, ssh, chmod, ssh-keygen) on your system to facilitate the ssh/rsync transfer. Cygwin can be used to accomplish this. You can easily install Cygwin from https://www.cygwin.com/. After installing, pluck a couple files from the bin/ folder and put them into the client/ directory. The binaries you need are:
chmod.exe rsync.exe ssh.exe ssh-keygen.exe
You may also need a couple libraries to ensure those binaries run:
cygcrypto-0.9.8.dll cyggcc_s-1.dll cygiconv-2.dll cygintl-8.dll cygpopt-0.dll cygspp-0.dll cygwin1.dll cygz.dll
- Next, you should update config.csv for your needs:
rsyncServerRemote - The address clients can connect to when remote (eg, a dynamic IP host) rsyncPortRemote - The port clients connect to when remote (eg, 22) rsyncServerHome - The address clients can connect to when on the local network (for example, 192.168.0.2) rsyncPortHome - The port clients connect to when on the local network (eg, 22) rsyncUser - The Synology user to backup as (eg, root) rsyncRootPath - The root path to back up to (eg, /volume1/backup) vcsUpdateCmd - If set, the version control system command to use prior to backup up (eg, svn up)
- The version control update command (%vcsUpdateCmd%) can be set to run a version control update on your files prior to backing up. This can be useful if you have a VCS repository that clients can connect to. It allows you to make remote changes to the backup scripts, and have the clients get the updated scripts without you having to log into them. The scripts are updated each time start-backup.cmd is run. For example, you could use this command to update from a svn repository:
vcsUpdateCmd,svn up
If you are using a VCS system, you should ensure you have the proper command-line .exes and .dlls in the client/ directory. I’ve used Collab.net’s svn.exe and lib*.dll files from their distribution (https://www.collab.net/downloads/subversion/).
During client setup, you simply need to log into the machine, checkout the repository, and setup a scheduled task to do the backups (see below). Each time a backup is run, the client will update its backup scripts first.
The client package is now setup! If you’re using %vcsUpdateCmd%, you can check the client/ directory into your remote repository.
Client Setup
For each client you want to backup, you will need to do the following:
- Generate a private/public key pair for the computer. You can do this by running ssh-keygen.exe, or have generate-client-keys.cmd do it for you:
generate-client-keys.cmd
or
generate-client-keys.cmd [computername]
If you run ssh-keygen.exe on your own, you should name the files rsync-keys-[computername]:
ssh-keygen.exe -t dsa -f rsync-keys-[computername]
If you run ssh-keygen.exe on your own, do not specify a password, or clients will need to enter it every time they backup.
- Grab the public key out of rsync-keys-[computername].pub, and put it into your Synology backup user’s .ssh/authorized_keys:
vi ~/.ssh/authorized_keys
You will want to prefix the authorized key with your validation command. It should look something like this
command="[validate-rsync.sh location] [backup volume root]" [contents of rsync-keys-x.pub]
For example:
command="/root/.ssh/validate-rsync.sh /volume1/backup/MYCOMPUTER" ssh-dss AAAdsadasds...
This ensures that the public/private key is only used for rsync (and can’t be used as a shell login), and that the rsync starts at the specified root path and no higher (so it can’t destroy the rest of the filesystem).
- Copy backup-TEMPLATE.cmd to backup-[computername].cmd
- Edit the backup-[computername].cmd file to ensure %rsyncPath% is correct. The following DOS environment variable is available to you, which is set in config.csv:
%rsyncRootPath% - Remote root rsync path
You should set rsyncPath to the root remote rsync path you want to use. For example:
set rsyncPath=%rsyncRootPath%/%COMPUTERNAME%
or
set rsyncPath=%rsyncRootPath%/bob/%COMPUTERNAME%
%rsyncRootPath% is set in config.csv to your Synology backup volume (eg, /volume1/backup), so %rsyncPath% would evaluate to this if your current computer’s name is MYCOMPUTER:
/volume1/backup/MYCOMPUTER
You can see this is the same path that you put in the authorized_keys file.
- Edit the backup-[computername].cmd file to run the appropriate rsync commands. The following DOS environment variables are available to you, which are set in start-backup.cmd:
%rsyncStandardOpts% - Standard rsync command-line options %rsyncConnectionString% - Rsync connection string
For example:
set cmdArgs=rsync %rsyncStandardOpts% "/cygdrive/c/users/bob/documents/" %rsyncConnectionString%:%rsyncPath%/documents echo Starting %cmdArgs% call %cmdArgs%
- Copy the client/ directories to the target computer, say C:\backup. If you are using %vcsUpdateCmd%, you can checkout the client directory so you can push remote updates (see above).
- Setup a scheduled task (via Windows Task Scheduler) to run start-backup.cmd as often as you wish.
- Create the computer’s backup directory on your Synology NAS:
mkdir /volume1/backup/MYCOMPUTER
The client is now setup!
Source
As noted above, the source for these scripts is available on Github:
https://github.com/nicjansma/synology-windows-ssh-rsync-backup
If you have any suggestions, find a bug or want to make contributions, please head over to GitHub!
Scenario:
The goal is to have files from Windows, backed up to the Linux server (a Synology
NAS), in a secure way. In this example, I have used a Linux host as a backup server, and a Microsoft Windows 10 PC as a client.
In this example, I’ve used windows 10 rsync over SSH.
I’ve added a layer of security by removing an attack vector. The Linux backup server cannot be accessed remotely via SSH.
The Windows 10 PC has no access to the backup server; it can’t access the SSH service on the backup server — in fact, it cannot access any TCP nor UDP ports on the backup server, and it doesn’t need to.
Requirements:
- Windows 10 (running Microsoft OpenSSH) (https://github.com/PowerShell/Win32-OpenSSH)
- Linux or Synology NAS (running an with SSH client, rsync client, crond (to make the backup script run at regular intervals))
- Cygwin (https://cygwin.com)
NOTE: I do not recommend using the ‘DeltaCopy’ product because it comes with an old, insecure version of rsync - Firewall rules on Windows 10 (configured to allow incoming connections on TCP port 22)
- (optional) A backup agent on Windows 10, to compress the files into a ZIP file
Here’s how it works:
1) The Windows PC will run Microsoft OpenSSH server (sometimes the thought of this makes me shudder but, it works)
2) The Windows PC runs the backup agent which backs up the files, compressed them into .ZIP archives, and stores them on an attached USB drive.
3) The Linux backup server has an SSH client & rsync client and, at regular intervals, it will SSH in to the Windows 10 PC to download all of the backups, using rsync to determine which files it already has
Method:
Step 1)
4 ноября 2012
Понадобилось организовать регулярный бэкап в локальной сети через rsync. Так как уже имеется NAS Synology DS212+, буду использовать его.
Источников данных несколько. Пусть это будут сайты. Для каждого необходимо взять файлы и дамп базы.
Настройка NAS
Control panel -> File Services -> rsync -> Enable rsync service.- Создаём нового пользователя
Control panel -> Users -> Create. - Имя обязательно должно быть
rsync, группаusers, права на чтение/запись шарыNetBackupи разрешение использоватьrsync. Control panel -> File Services -> rsync -> Enable rsync account.
Особенности
- Synology создаёт одну шару
NetBackupкак модуль rsync. Других по умолчанию нет. - По умолчанию можно использовать либо пользователя
admin, что не очень безопасно,
либо создать пользователяrsync. Именно с таким именем. - Указывать наш NAS rsync-у будем в виде
[email protected]::NetBackup/. - У пользователя rsync должны быть права на
NetBackup.
Linux
Напишем скриптик и поставим на крон.
#!/bin/bash export RSYNC_PASSWORD=your_rsync_user_password backupServer=rsync@nas.ip::NetBackup/ currentDate=`date +%F` currentMonth=`date +%Y-%m` rsyncTmp=/tmp/rsync/ rsyncMkdir=${rsyncTmp}mkdir/ rsyncDB=${rsyncTmp}db/ dbusername=root dbpassword=mysql_root_password rsync_mkdir () { mkdir -p ${rsyncMkdir}$1 rsync -v --archive --compress --progress ${rsyncMkdir} $2 rm -R ${rsyncMkdir} } rsync_db () { mkdir -p ${rsyncDB} mysqldump -u $dbusername --password=$dbpassword $1 | gzip -9 > ${rsyncDB}${1}_${currentDate}.sql.gz; rsync -v --archive --compress --progress --partial ${rsyncDB} $2 rm -R ${rsyncDB} } rsync_dir () { rsync -v --archive --compress --progress --delete-after --force --partial $1 $2 } backupdir=example.com/ backupdirMonth=${backupdir}${currentMonth}/ rsync_mkdir ${backupdirMonth} ${backupServer} rsync_db example_com1 ${backupServer}/${backupdir} rsync_db example_com2 ${backupServer}/${backupdir} rsync_dir /var/www/example.com/ ${backupServer}/${backupdirMonth}
Windows
Под Windows я попробовал DeltaCopy.
Бесплатная, работает. Настраивается вот так.
Windows 10: WSL — Rsync from Synology NAS to Windows 10
Discus and support WSL — Rsync from Synology NAS to Windows 10 in Windows 10 Network and Sharing to solve the problem; Hello,
I have installed WSL and Ubuntu on my Windows 10 computer. It works like a champ.
I can ssh into my Synology NAS and rsync works.
I…
Discussion in ‘Windows 10 Network and Sharing’ started by Ha567, May 3, 2019.
-
WSL — Rsync from Synology NAS to Windows 10
Hello,
I have installed WSL and Ubuntu on my Windows 10 computer. It works like a champ.
I can ssh into my Synology NAS and rsync works.
I understand how to set the permissions in the rsync command so that they are correct on the NAS but when I have to sync a NAS folder back to the Windows box I am not sure what permissions to apply. If I use the p option in the rsync command as a test when syncing to the NAS from the Windows box the user file permissions are RWX, user directory permissions are RWX and group/other are left as —.
Is this telling me to set the permissions within the rysnc command as —chmod=Du=rwx,Fu=rwx when syncing NAS to Windows? If not what should I use?
As a side note when I look at the files on the Windows box via the Ubuntu command line the permissions are listed as rwxrwxrwx for each directory and file.
Regards,
Chris
-
Windows 10 File Explorer cannot access Synology NAS
I am using a HP laptop with Windows 10 Home and suddenly over the last several days a Synology NAS cannot be accessed from the laptop.
More information:
The version of Windows 10 Home — 1803
I have two other PC in the house and both can access the Synology NAS
I also have several Android tablets — they can access the NAS
On the laptop (with the issue) I also have a Synology management software product — It CAN access the NAS and open files
I originally mapped the NAS several months ago on the laptop and the mapped drives worked as expected until yesterday,
Yesterday I started getting messages saying «… the network path was not found.» every time I tried to access/map the NAS
After several reboots of the laptop (yesterday) I was finally able to map the NAS, but only by typing in «\\ (NAS Name) \» before I started the mapping process.
This morning the same mapping (that worked yesterday evening) is not working and giving the same error message I saw yesterday morning.
Just to recap
Running laptop — windows 10 Home (1803)
Mapped NAS drives worked fine until yesterday
Synology management software on same PC can access the NAS and open files
Several other PCs can open files
I was able to re-establish connections yesterday by specifying the NAS name when I restarted the mapping
Today the mapping does not work (again).
-
Connecting Windows to a NAS
I recently bought a 10G card for my Synology NAS. Windows doesn’t see it and the NAS has no «add new device» command. Of course, the NIC came with drivers, but where to install them?
Anyone?
PS: please don’t tell me to look in the list of devices accepted by my Synology NAS, their price is prohibitive.
-
WSL — Rsync from Synology NAS to Windows 10
Getting access to my data on Synology NAS
Hi, I have a problem with my Synology DS211j – please any help would be appreciated:
I bought the Synology NAS about a year ago but after setting-up the NAS I had a stroke :-(.
I am now trying to re-lean my NASs but am struggling with my Synology:
I can see the NAS has two disk – a 1Gb disk “Not installed”, and a 2Gb disk “Installed”. As I think I should have some important data, I need to work out what I have on the 2Gb disk or possible even on the 1 Gb disk?
So the 2Gb disk says it is installed but I don’t know how to get to the data from the disk (and I’m trying to be careful so that I don’t lose the data)?
ny advise on the steps on get ting access to the date would be really appreciated!
WSL — Rsync from Synology NAS to Windows 10
-
WSL — Rsync from Synology NAS to Windows 10 — Similar Threads — WSL Rsync Synology
-
Access Synology NAS on network
in Windows 10 Network and Sharing
Access Synology NAS on network: When attempting to access the folders and files on my Synology DS418play I’m confronted with «You do no have permission to access\\DS418Play Contact your administror to obtain permission.»I’ve seen reference on the web to this predicament many times in an attempt to solve… -
Windows 10 cannot find the Synology NAS in my network
in Windows 10 Network and Sharing
Windows 10 cannot find the Synology NAS in my network: Windows 10 Pro OS Build 19042.1165 Version 20H2 dates 3/14/2021 Using the Synology assistant to find the NAS I get a message «No Synology Server was found on the local network.» The NAS is hard wired to my private server (AT&T) modem. Synology says it is a local network… -
Trouble connecting to Synology DS218J NAS
in Windows 10 Network and Sharing
Trouble connecting to Synology DS218J NAS: Hi,I have a Synology DS218J on SMB. I have been able to access it via Windows Explorer with \\hostname just fine, but I just tried today and it no longer works. I get the following error message when I try to access a folder within the NAS
[img]
I get the following error…
-
Re-using a hard drive from Synology NAS in windows 10 PC
in Windows 10 Ask Insider
Re-using a hard drive from Synology NAS in windows 10 PC: I have a Synology NAS 918+ that I want to remove the 4TB HD and use that hard drive in windows 10 pc. I’m looking for some advice on how I could reformat that drive.submitted by /u/tekstein1979
[link] [comments]… -
problems with Synology NAS on Windows 10 1809
in Windows 10 Installation and Upgrade
problems with Synology NAS on Windows 10 1809: Below are my impressions on version 1809 on two different machines.Yesterday I upgraded to ver.1809 build 17763.292 and installed all updates. All seems to work well except for the connection with my Synology NAS. The disk station is has the latest update and is connected…
-
WIN10 / SYnology NAS
in Windows 10 Network and Sharing
WIN10 / SYnology NAS: Howdy,A couple months ago I had an update and suddenly every time the PC goes to «sleep» I lose connection to My NAS. The odd thing is I can see the folders even though the show as a mapped drive they show an with an X. Once I try to access a file it says it can’t find…
-
Rsync for Windows 10
in Windows 10 Drivers and Hardware
Rsync for Windows 10: Hello,I store my photos and some other files in one hard disk. I would like to use another hard disk as backup. Does Microsoft have an equivalent to Rsync for Windows 10?
Thanks…
-
Can’t connect to Synology NAS
in Windows 10 Network and Sharing
Can’t connect to Synology NAS: I hope you can help, thanks…I don’t have the password for our new Sysnology NAS (I suffered from a stroke just as I was re-installing the NAS last June). Is there anyway to get access to the data that was copied into the NAS please?
Thanks!
75145
-
MediaMonkey and (Synology) NAS Problem
in Windows 10 Network and Sharing
MediaMonkey and (Synology) NAS Problem: I noticed that Macrium Reflect Free had stared to fail on scheduled backups and in fact was unable to connect to my NAS nor could file explorer, both using the server name. Connection could be made using the IP address. I could see the NAS as a media device but not as a…
Users found this page by searching for:
-
synology recover data from drive with wsl
,
-
synology rsync windows 10
,
-
wsl rsync reach from windows
,
- synology wsl,
- rsync from windows 10 to synology,
- synology install rsync hyperbackup windows,
- rsync on synology,
- nas options with wsl,
- install rsync on windows 10,
- set up rsync connection windows synology,
- windows 10 wsl rsync 2019,
- synology works with rsync,
- win10 rsync server,
- rsync to synology nas windows,
- wsl rsync to nas
