Rsync windows and linux

How to use rsync from Windows PC to remote Linux server?

How do I use the rsync command from a local Windows 7 machine to a remote Linux server? What software is needed on the Windows 7 machine to use rsync ? The remote Linux server is using Amazon’s Linux AMI. The command rsync is already enabled on the machine and I can edit any needed access to the machine. This is for the purposes of setting up a web server on the remote machine and the editing on my local machine and keeping the files in sync. I do not want two-way access between the machines, I am only going to be editing files on my local machine and keeping them updated on the remote machine. UPDATE: I installed cygwin on my Windows 7 machine and installed the rsync package. Can someone provide the steps to set up the connection from the Windows 7 machine to the Linux server remotely? Say I want to have a folder called C:\www on my Windows machine and keep it updating \var\www on my remote machine, how do I do that? It’s not a backup per se, it updates the files that I edit with my local computer.

7 Answers 7

I have MinGW (also known as ‘Git Bash’) on Windows 7, and a batch file that runs rsync to back up files on an external drive on a remote linux computer. Here’s the batch file ( my_rsync_file.bat )

REM Changing directory. (assuming we are in G:/My Documents/My Various Things) cd ../ REM starting rsync. bash -c "rsync -avzh -P --stats --timeout=60 --exclude Downloads . 'my_remote_linux_computer@128.95.170.200:/media/my_remote_linux_computer/LaCie/My\ Documents'" 

Here’s a bit of line-by-line explanation:

REM Changing directory. (assuming we are in G:/My Documents/My Various Things)

This just emits a message to remind me what’s going on.

This changes directory one level up from where the batch file is (to ‘My Documents’). The batch file is in an external drive on my Windows computer. I want to sync all of the ‘My Documents’ folder on this external drive with a folder of the same name on an external drive on my remote linux computer.

Just prints another message.

bash -c «rsync -avz -P —stats —timeout=60 —exclude Downloads . my_remote_linux_computer@128.95.155.200:/media/my_remote_linux_computer/LaCie/My\\ Documents»

bash : starts MinGW which has a built-in rsync library
-c : not sure what this does
rsync : library to sync files, comes with MinGW
-avzh : a-Archive, v-Verbose, z-Compress, h-Human-readable, these are the common options (more: http://linux.die.net/man/1/rsync)
-P : show progress for big files so I know if it’s frozen or not
—stats : show summary of how many files and bytes transferred at the end
—timeout=60 : kill it after 60 seconds if it gets stuck
—exclude omit files/directories from sync, in this case I exclude a directory called ‘Downloads’
. : indicates to sync all the contents of ‘My Documents’ (expect the specified thing to exclude in the line above)
my_remote_linux_computer : name of my remote linux computer (not it’s actual name 😉
@128.95.155.200 : the IP addres of my remote linux computer, from https://www.whatismyip.com/ (not my actual IP address 🙂
/media/my_remote_linux_computer/LaCie/My\\ Documents : the path to the directory on my remote linux computer that I want to receive the files. It’s an external drive.

Читайте также:  Astra linux qt creator версия

Note that the space in «My Documents» is escaped with two backslashes, and the full name and directory of the remote destination is surrounded by double quote marks.

When I start double-click on the bat file I’m prompted for the password for my remote linux computer. When it completes I get some summary output and am prompted to press any key to close.

Источник

1. Use the remote connection desktop provided by windows

  1. win + R opens the operation interface
  2. Enter mstsc to open the remote connection desktop
  3. Enter the address, user name and password of the computer to be connected
  4. When connecting to remote windows, the following error occurs:
  5. win + R opens the operation interface
  6. Enter gpedit MSc open policy
  7. Find the path: «computer configuration» — > «management template» — > «system» — > «credential allocation» — > «encrypted database correction»
  8. Edit «encrypted database correction», as shown in the following figure
  9. Just connect to the remote desktop again

2. windows Server Deployment

Because the synchronization target here is windows, we need to deploy the server on windows

1.1 download

Because the latest version of windows server has been charged, we use the latest free version 4.1.0 here, Click here to download

After downloading, unzip it

1.2 installation

  1. Click cwRsyncServer_4.1.0_Installer.exe to install
  2. Select Save folder
  3. User name and password are set here: user name is customized and password is customized (if the installed computer has a login password, it must be a login password)
  4. Click Install to complete the installation

1.3 configuration

uid = 0 gid = 0 use chroot = false strict modes = false hosts allow = * log file = rsyncd.log # Module definitions # Remember cygwin naming conventions : c:\work becomes /cygwin/c/work # # [test] # path = /cygdrive/c/work # read only = false # transfer logging = yes [rsync_linux246] path = /cygdrive/d/hehuan_test/rsync_workspace/rsync_linux246/ ignore errors read only = no list = no hosts allow = 192.168.*.0/255.255.255.0 auth users = apache secrets file = /cygdrive/d/hehuan_test/rsync_workspace/rsyncd.password [rsync_windows242] path = /cygdrive/d/hehuan_test/rsync_workspace/rsync_windows242/ ignore errors read only = no list = no hosts allow = 192.168.*.0/255.255.255.0 auth users = apache secrets file = /cygdrive/d/hehuan_test/rsync_workspace/rsyncd.password
  1. New directory: Rsync_ workspace\rsync_ Linux 246 and rsync_workspace\rsync_windows242
  2. New file: rsync_workspace\rsyncd.password, as follows:
Читайте также:  Linux имя сетевой карты

  1. Set Rsync_ Linux 246 and Rsync_ The permissions of the windows242 directory are Rsync_ Take Linux 246 as an example: right click rsync_linux246 directory, select Properties
  2. Modify rsyncd Password permission is 600
D:\hehuan_test> D:\hehuan_test>cwRsyncServer_4.1.0\ICW\bin\chmod 600 rsync_workspace\rsyncd.password cygwin warning: MS-DOS style path detected: rsync_workspace\rsyncd.password Preferred POSIX equivalent is: rsync_workspace/rsyncd.password CYGWIN environment variable option "nodosfilewarning" turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames D:\hehuan_test>

1.4 start rsync service

  1. Open services as follows msc
  2. The setting results are as follows:

3. Synchronize Linux to windows

3.1 preparation

[root@node ~]# [root@node ~]# telnet 192.168.*.* 873 Trying 192.168.*.*. Connected to 192.168.*.*. Escape character is '^]'.

The above indicates that the connection is successful; If the connection fails, it may be a firewall problem. Close the firewalls on both sides or open port 873

[root@node ~]# [root@node ~]# yum install -y rsync.x86_64 [root@node ~]#
[root@node ~]# [root@node ~]# cat /etc/rsyncd.password apache [root@node ~]# [root@node ~]# chmod 600 /etc/rsyncd.password [root@node ~]#

3.2 synchronization

[root@node ~]# [root@node ~]# rsync -avz /data/minio/hnjgzd/uploadFiles/ apache@192.168.*.*::rsync_linux246 --delete --progress --include '249524666' --include '4297753547' --include '75118392427' --exclude '/*' --password-file=/etc/rsyncd.password sending incremental file list ./ . ellipsis. sent 160,824,910 bytes received 10,715 bytes 7,480,726.74 bytes/sec total size is 165,640,562 speedup is 1.03 [root@node ~]#

3.3 real time synchronization with inotifywait

[root@node ~]# [root@node ~]# yum install -y epel-release.noarch [root@node ~]# [root@node ~]# yum install -y inotify-tools [root@node ~]#
[root@node ~]# [root@node ~]# cat rsync.sh #!/usr/bin/env bash source_dir=/data/minio/hnjgzd/uploadFiles/ /usr/bin/inotifywait -mrq --timefmt '%y-%m-%d %H:%M' --format '%T %w %f %e' -e create,attrib,modify,delete $ | while read date time dir file type do /usr/bin/rsync -avz $ apache@192.168.*.*::rsync_linux246 --delete --progress --include '824482527' --include '3787639635' --include '38925414132' --exclude '/*' --password-file=/etc/rsyncd.password echo "time: $ $, file: $$, Change type: $, Synchronization completed" >> /root/rsync_file.log done [root@node ~]#
[root@node ~]# [root@node ~]# nohup sh /root/rsync.sh >> /root/rsync.log 2>&1 & [root@node ~]#
[root@node uploadFiles]# [root@node uploadFiles]# pwd /data/minio/hnjgzd/uploadFiles [root@node uploadFiles]# [root@node uploadFiles]# touch test.txt [root@node uploadFiles]# [root@node uploadFiles]# rm test.txt -f [root@node uploadFiles]#

4. Synchronize windows to windows

4.1 download and decompression

The installation file location is shown in the figure below
2. Decompression
After decompression, you can use it directly

4.2 connection test

C:\Users\dell> C:\Users\dell>telnet 192.168.*.* 873 C:\Users\dell>

If the connection fails, it may be a firewall problem. Close the firewalls on both sides or open port 873

4.3 password file

  1. Create a password file in the directory D:\hehuan_test\rsync_workspace\rsyncd_client.password
  2. rsyncd_ client. The content of the password file is apache

4.4 synchronization script

Script path: D:\hehuan_test\rsync_workspace\rsync.bat

%date% %time% d: d:\hehuan_test\cwRsyncClient_6.2.1\bin\rsync -avz data/hnjgzd/uploadFiles/ apache@192.168.*.*::rsync_windows242 --delete --progress --include '224951639' --include '4837417346' --include '44899989817' --exclude '/*' --password-file=d:\hehuan_test\rsync_workspace\rsyncd_client.password %date% %time%

4.5 creation of scheduled task plan

  1. Open compmgmt. As follows msc
  2. New scheduled task execution plan
  3. General settings

  1. Trigger settings

  2. Operation settings
    Contents filled in the program or script box: D: \ Hehuan_ test\rsync_ workspace\rsync. bat >> D:\hehuan_ test\rsync_ workspace\rsync. log
  3. Scheduled execution plan setting completed
Читайте также:  Чем хорош linux mint

Posted by abduljan on Sun, 16 Jan 2022 17:23:45 +1030

  • Java — 5996
  • Python — 2604
  • Algorithm — 1737
  • Javascript — 1708
  • Back-end — 1577
  • Front-end — 1561
  • Linux — 1389
  • C++ — 1378
  • data structure — 1135
  • Database — 953
  • Spring — 922
  • C — 836
  • MySQL — 835
  • Android — 683
  • Spring Boot — 660
  • Vue.js — 549
  • Design Pattern — 543
  • Operation & Maintenance — 509
  • Deep Learning — 487
  • Interview — 459

Источник

Rsync from Windows to Linux over SSH – How to perform

Over the years we have assisted many customers to transfer and synchronize data between different machines using the rsync command.

Even though the rsync protocol can be pretty simple to use, some of its more advanced features may surprise you.

As part of our Server Management Services, we assist our customers with several Rsync queries.

Today, let us see how to perform Rsync from Windows to Linux over SSH.

Rsync and SSH

We can use rsync to transfer and synchronize data between different machines and directories. Using the Secure Shell (SSH) protocol, we can copy the files securely to another location.

Compared to other methods for copying files, the Rsync tool has many benefits. It uses both compression and decompression to send and receive files.

In addition, the tool only transfers new or updated files saving on bandwidth and bringing faster transfer times.

Rsync from Windows to Linux over SSH

Although Rsync is built to run on Unix-like systems, we can use it on Windows. With the help of Cygwin which produces a wonderful Linux API, we can run rsync. Depending on the computer we can either download the 32-bit or 64-bit version.

We can install rsync and ssh using Cygwin. Let us see how our Support Engineers perform this.

Steps to install Cygwin:

When prompted accept all the defaults to download from the internet > Accept the install directory C:cgywin64 > Install for All users > Set the local Package Directory to the Desktop > Internet = Direct Connection > Choose a Download site > Next.

We can perform rsync operation using the command given below:

rsync /cygdrive/c/users/Owner/Pictures/ -av -e ssh xyz@192.168.1.10:/var/files/ImageSync/

Here, /cygdrive/c/users/Owner/Pictures/ is the location of files in Windows machine. Whereas, /var/files/ImageSync/ is the location of files in Linux machine.

[Need help with the transfer? We’d be happy to assist]

Conclusion

To conclude, we saw an effective method our Support Techs employ to perform Rsync from Windows to Linux over SSH.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

Источник

Оцените статью
Adblock
detector