This file explains how to synchronize observation data on the workstation & monitor (Win 10) in NTHU Observatory to CICA cluster (Linux) in NTHU IoA by rsync.
Download Cygwin (https://cygwin.com/index.html, setup-x86_64.exe) to workstation.
- Double click on
setup-x86_64.exe
to start installation. - Click
Next
. - Choose
Install from Internet
. - Root Directory
C:\cygwin64
, install forAll Users
. - Local Package Directory
C:\cygwin64
. - Select Your Internet Connections
Use System Proxy Settings
. - Choose A Download Site
http://ftp.ntu.edu.tw
. - There will be some default plugins, choose additional plugins
Net > openssh, Devel > git, Editors > vim, Admin > cygrunsrv, Net > rsync
in their newest version. - Install & Finish.
Note:
If you want to install other functions/packages in the future, run setup-x86_64.exe
again and choose the ones you need.
Note:
If you have set user password already, skip this step.
- Right click on "This PC" ->
Manage
. System Tools
->Local Users and Groups
->Users
.- Right click on your user, here
observatory
->Set Password
->Proceed
-> type new password.
- Right click on "This PC" ->
Properties
->Advanced System Settings
. Advanced
tab ->Environment Variables
.System variables
->New
-> Variable name: CYGWIN, Variable value: ntsec tty.- In
System variables
, findPATH
->Edit
->New
->C:\cygwin64\bin\
.
- Run Cygwin as administrator.
- Type
ssh-host-config
, it will generate some key files automatically. - It will ask
Should StrictModes be used? (yes/no)
->yes
. - Activate ssh
net start cygsshd
. - Syncronize users and password of Cygwin and Windows.
mkpasswd -cl > /etc/passwd mkgroup --local > /etc/group
- Test if ssh works
ssh localhost
.
(https://virtualizationreview.com/articles/2020/05/21/ssh-server-on-windows-10.aspx)
If net start sshd
doesn't work, it means you haven't install ssh server on windows.
- Go to
Windows Settings
,Apps
,Optional features
, clickAdd a feature
, selectOpenSSH Server
, and clickInstall
. - Launch Powershell as Administrator.
- See the status of the service:
Get-Service sshd
. - Start the service:
Start-Service sshd
. - Verify that the service was running:
Get-Service sshd
and make sure the status is 'Running'. - Let SSH service to start every time the system booted up:
Set-Service -Name sshd -StartupType 'Automatic'
. - To check and make sure that the port for the SSH server was open:
Get-NetFirewallRule -Name *ssh*
. - Test if ssh works
ssh localhost
.
Allow connection from outside.
Control Panel
->System and Security
->Windows Defender Firewall
->Advanced settings
.Inbound Rules
-> createNew Rule
.Rule type: Port
,Protocol and Ports: TCP, Specific local ports: 22
,Action: Allow the connection
,Profile: Domain, Private, Public
,Name: OpenSSH SSH Server (sshd)
Note:
Rsync requires installation on both machines. If rsync is not installed on your backup destination (perhaps a Linux machine), please install it.
Rsync is a useful tool in doing remote backup. There are different types of backup that can be choose using rsync while scp can only do full backup.
- Full backup copies the full data set to the destination which consumes time and storage space.
- Incremental backup only back up the files that are changed since the last backup.
- Differential backup is similar to incremental backup while it compares with the last full backup rather than any type of backup.
This is how rsync works:
rsync -[option] source destination
If it requires login to other machines, it will ask you for password after this command. We want to backup files from workstation, monitor (Windows) to CICA (Linux). For safety issues, we give commands on CICA:
rsync -avP [email protected]:/[directory]/ /data/nthuobs/[directory]/
rsync -avP [email protected]:/[directory]/ /data/nthuobs/[directory]/
-a, –archive archive files and directory while synchronizing ( -a equal to following options -rlptgoD)
-v, –verbose Verbose output
-P, –progress show the sync progress during transfer
The cron service can schedule tasks on a repetitive basis. We can put our .sh files in cron job to run daily backups. To do automatic backups, we don't want to type password every time so we use sshpass.
sshpass -p [password] rsync -avP [email protected]:/[directory]/ /data/nthuobs/[directory]/
sshpass -p [password] rsync -avP [email protected]:/[directory]/ /data/nthuobs/[directory]/
Put the command lines in a .sh file, set the path of .sh file to cron and it will do automatic backup every certain time.
Note:
Give Andrew this .sh file and he will help with the cron part.
- https://faqbook.net/cygwin-install-ssh
- https://searchdatabackup.techtarget.com/tip/Data-backup-types-explained-Full-incremental-differential-and-incremental-forever-backup
- https://www.linuxtechi.com/rsync-command-examples-linux/
Created on 2020/09/16. Last revised on 2021/03/29.