Меню Рубрики

Rsync server windows cygwin

Rsync server windows cygwin

cygwin-rsyncd: Rsyncd for Cygwin

Download and run cygwin-rsyncd-3.1.2.1_installer.exe to install rsyncd on your WinXX client for doing BackupPC backups.

Clone the git repository at https://github.com/backuppc/cygwin-rsyncd.git if you want to customize and build your own cygwin-rsyncd executable (eg: presetting some configuration parameters for your site).

Thanks to Ray Frush, this distribution now comes with the NSIS installer, which wraps everything in a single .exe. (See nsis.sourceforge.net.). This was based on the NSIS wrapper used by cwRsync. This particular version was updated by Yves Ouvrie.

This distribution includes rsync 3.1.2, and a handful of cygwin 2.6.0 libraries. It was built using NSIS 3.0a0.

When you download and run cygwin-rsyncd-3.1.2.1_installer.exe, the cygwin and rsync files are installed in c:\rsyncd. A new windows service called RsyncServer is created and activated (ie: run). The c:\rsyncd directory will have an uninstall executable which will remove the service and installation files.

You will need to edit the c:\rsyncd\rsyncd.conf and c:\rsyncd\rsyncd.secrets files to set your client-specific shares, backup user name and password. You should restart the Windows RsyncServer service to get the new settings.

To ensure initial security, the c:\rsyncd\rsyncd.secrets file initially has no users, and the c:\rsyncd\rsyncd.conf only allows connections from two specific IP addresses. So unless you edit those two files you won’t be able to connect to the rsyncd server.

If you have Windows firewall enabled then you will need to allow rsync to listen on TCP port 873. You can do that through the WinXX firewall menus. You can also make that rule specific to the BackupPC server IP addresses, so no other hosts can contact the rsyncd server on this client.

Warning about installing multiple cygwin1.dll files

If you already have Cygwin installed then you should not install the cygrunsrv.exe and cygwin1.dll files. Installing multiple versions of the same DLL is a bad idea. Instead, you should manually install the rsync.exe executable in your Cygwin hierarchy and use the existing Cywin utilities.

In fact, a package like this that contains a local cygwin1.dll is discouraged by the cygwin community, since if the user later installs the real cygwin there will be two installed cygwin1.dll’s. Please don’t complain to the cygwin user list if you do this and things break.

Cygwin is a great package with a simple installer. If you want to use Cygwin then use the setup.exe program at http://cygwin.com, and don’t use the cygwin1.dll from this installation. You can easily install rsync from the Cygwin installer.

Setting Up BackupPC To Use Windows rsyncd

The following options will have to be set in either the global config.pl or the per-host config.pl files. For more information see the BackupPC documentation:

Building a New NSIS Wrapped Executable

The small tree of files to install, and the nsi script backuppc_rsync-server.nsi are available at https://github.com/backuppc/cygwin-rsyncd.git. This isn’t program source code — it is the source tree that contains the executables and libraries for building cygwin-rsyncd-3.1.2.1_installer.exe.

If you want to change any of the installed files (eg: configuration files), perhaps with site-specific settings, then edit the files as necessary.

To create the .exe installer, you will need to install NSIS from nsis.sourceforge.net. When you run NSIS, tell it to load/run the backuppc_rsync-server.nsi file, and it will create a .exe file that you can rename. To avoid version confusion, you should use a different name or version from the standard distribution, cygwin-rsyncd-3.1.2.1_installer.exe.

See license.txt for licenses for cwRsync, Cygwin and Rsync.

If you install via the NSIS .exe wrapper, the license file will be C:\rsyncd\license.txt.

About

rsyncd installer with cygwin for windows backup clients

Источник

1С и Linux

Пишу для себя, чтобы не забыть как делал. 95 % рабочее. На комментарии отвечаю, когда увижу.

воскресенье, 26 мая 2019 г.

Установка RSync в Windows Cygwin 32 бит

Найти и установить rsync

Скоприровать файлы (32 bit)

c:\cygwin\bin\rsync.exe
c:\cygwin\bin\cygwin1.dll
c:\cygwin\bin\cygiconv-2.dll
c:\cygwin\bin\cyggcc_s-1.dll
c:\cygwin\bin\ cygpopt-0.dll
c:\cygwin\bin\ cygintl-8.dll

>rsync —version
rsync version 3.1.2 protocol version 31
Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, no xattrs, iconv, symtimes, prealloc

rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.

Создать файл c:\rsync\ rsync.conf

use chroot = no
pid file = rsync.pid
strict modes = false

[backup]
path=/cygdrive/D/Copy/Backup/1
read only = no

Сохранить.

Создать файл c:\rsync\ rsync.bat

del /F /Q c:\rsync\rsync.pid
rsync.exe —daemon —config=/cygdrive/c/rsync/rsync.conf —log-file=/cygdrive/c/rsync/rsyncservice.log —address=192.168.0.2

Сохранить.

Запускать планировщиком при входе в систему
c:\rsync\ rsync.bat

или по необходимости.

>rsync -avz 192.168.0.2::backup /cygdrive/D/z —progress

Настройка Ubuntu 16.04

$ sudo nano /etc/default/rsync

$ sudo nano /etc/rsyncd.conf
# create new
# any name you like

[backup]# destination directory to copy

path = /home/backup
# hosts you allow to access

hosts allow = 192.168.1.0/255.255.255.0
hosts deny = *
list = true
uid = root
gid = root
read only = false

Сохранить.

$ sudo mkdir /home/backup
$ sudo systemctl enable rsync
$ sudo systemctl start rsync

RSync. Примеры использования

>rsync 192.168.0.5::backup
drwxr-xr-x 4,096 2019/05/27 19:43:53 .
drwxrwx— 4,096 2019/04/15 17:56:35 backups

>rsync -avz /cygdrive/C/pg_probackup/backups 192.168.0.5::backup —progress

Синхронизация в папку с датой

>rsync —delete -backup —backup-dir=/backup-%DATE:

0,2% -avz /cygdrive/C/pg_probackup/backups 192.168.0.5::backup /backup-%DATE:

rsync —delete -backup —backup-dir=/backup-%DATE:

0,2% -avz /cygdrive/C/pg_probackup/backups 10.8.0.1::backup /backup-%DATE:

rsync —delete -backup —backup-dir=/backup-%DATE:

0,2% -avz /cygdrive/D/copy/Arhiv 10.8.0.1::backup/backup-%DATE:

0,2% —progress

rsync —delete -avz 10.8.0.1::backup /cygdrive/D/z —progress

Заменить *.exe и *.dll на 32 бит из c:\cygwin\bin\
Еще понадобится c:\cygwin\bin\cygrunsrv

use chroot = false
strict modes = false
hosts allow = *
log file = rsyncd.log

# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
#
[diskc]
path = /cygdrive/c/
read only = false
transfer logging = yes

[diskd]
path = /cygdrive/d/
read only = false
transfer logging = yes

[diske]
path = /cygdrive/e/
read only = false
transfer logging = yes

[diskf]
path = /cygdrive/f/
read only = false
transfer logging = yes

c:/rsyncd/bin/rsync.exe —daemon —config=c:/rsyncd/rsyncd.conf —log-file=/cygdrive/c/rsyncd/rsyncservice.log —address=192.168.1.226

Пример:
g:/rsyncd/bin/rsync.exe -r /cygdrive/d/yandex_disk/backup_2019_04_18.7z 192.168.1.226::diskc/rsyncd —progress

Ручная регистрация службы RsyncServer

c:\rsyncd\bin\cygrunsrv -I «RsyncServer» -p /cygdrive/c/rsyncd/bin/rsync.exe -a «—config=/cygdrive/c/rsyncd/rsyncd.conf —daemon —no-detach» -o -t auto -e «CYGWIN=nontsec binmode» -1 /cygdrive/c/rsyncd/rsyncd-stdin.log -2 /cygdrive/c/rsyncd/rsyncd-stderr.log -y tcpip -f «Rsync daemon service»

c:\rsyncd\bin\cygrunsrv —verbose —start «RsyncServer»

Удаление службы RsyncServer

c:\rsyncd\bin\cygrunsrv —verbose —stop «RsyncServer»

Источник

SSH and Rsync within Cygwin

This post documents the steps I have used to setup SSH and Rsync within a Cygwin Windows environment.

Cygwin Setup
This is not an in-depth guide for installing Cygwin; although, installing Cygwin is a fairly simple process. In or to implement SSH and rsync functionality, a few non-default Cygwin packages will need to be installed.

    Download and run the Cygwin setup.exe program from http://cygwin.com/install.html

If you already have Cygwin installed, that should not be a problem. You can still run setup.exe to install additional Cygwin packages.

  • Proceed through the Cygwin setup process until you get to the «Select Packages» screen. From there, make sure the following packages are selected:
    • Net -> openssh
    • Net -> rsync
    • Admin -> cygrunsrv
    • Editors -> nano (optional, but I find it to be a very simple text editor to use in place of vi or emacs)
    • Web -> wget (optional, but useful for downloading files without a browser)

    Finish the Cygwin setup wizard allowing the selected packages, including any required dependency packages, to be installed.

      Right-click the Cygwin Terminal icon and then click «Run as Administrator».

    Note: On older versions of Windows such as XP and Windows Server 2003, the «Run as Administrator» option may not be available. In that case, simply double-click the Cygwin Terminal shortcut.

    In the Cygwin terminal, enter ssh-host-config and then press Enter. This should start an SSH setup script that will guide you through the rest of the setup.

  • The SSH setup script should ask you a series of questions. Answer the questions as follows:
    • Should privilege separation be used? – yes
    • Should this script attempt to create a new local account ‘sshd’? – yes
    • Do you want to install sshd as a service? – yes
    • Enter the value of CYGWIN for the daemon – tty ntsec
    • Do you want to use a different name? – no
    • Create new privileged user account ‘cyg_server’? – yes
    • Enter a password for the cyg_server account. — Enter a new password of your choice.
    • Re-enter the password for the cyg_server account. — Enter the password again.

    Start the SSH service by entering net start sshd into the Cygwin terminal and pressing Enter.

    At this point, you should be able to connect to the Windows computer via SSH. To test it out, use an SSH capable terminal program such as Putty. When logging in, use a local Windows user name and password.

    Cygwin Users
    Cygwin users are defined in the /etc/passwd file. Local users are added to this file by default when Cygwin is first installed. To add additional users to this file, including local and domain users, Cygwin includes a nifty utility called mkpasswd . To add a new Cygwin user, follow these steps:

      If the local or domain Windows user does not already exist, go ahead and create it first.

    Open a Cygwin terminal window and run the following command to add a local user:

    mkpasswd -l -u [user] >> /etc/passwd

    Or, to add a domain user, run the following command:

    mkpasswd -d [domain] -u [user] >> /etc/passwd

    If you’d like to verify the contents of the /etc/passwd file, you can view it by running the following command:

    To test out the new account, try to make an SSH connection with it.

    SSH Public/Private Key Pair
    It is possible to a create public/private key pair with which an SSH user can be authenticated without having to use a password. This can be useful when automating rsync connections over SSH. Otherwise, a password would need to be entered manually. In order to create and setup a public/private key pair for use with SSH and rsync, follow these steps:

      Login in to a terminal session of the client computer that will be connecting to the Cygwin server via SSH. This could be a Linux server, an AIX server, or possibly another Cygwin server (although not confirmed by me).

    On the client computer, run the following command:

    Accept the default location for the key by pressing Enter and make note of it for future reference.

    When prompted for a passphrase, just press Enter. Then, press Enter again when prompted for the passphase a second time.

    On the Cygwin server, make sure the .ssh sub-directory exists in the user’s home directory. If it does not exist, create it.

    Copy the public key file from the client computer to the Cygwin server. The public key file on the client computer should be named id_rsa.pub and should be located in the .ssh sub-directory of the user’s home directory if you accepted the default location. On the Cygwin server, the public key file should be copied to the user’s .ssh sub-directory. There are multiple ways to copy the file. To copy the public key file using scp, use a command similar to this:

    scp /home/[local user]/.ssh/id_rsa.pub [remote user]@[Cygwin server IP]:/home/[remote user]/.ssh/id_rsa.pub

    Note: The local user and remote user do not need to match.

    On the Cygwin server, rename the id_rsa.pub file to authorized_keys . If the authorized_keys already exists, simply append the contents of the id_rsa.pub to the end of it instead.

    At this point you should be able to make an SSH connection from the client computer to the Cygwin server without using a password. To test this, run the following command from the client computer:

    ssh [user]@[Cygwin server IP]

    Note: You should not be prompted for a password. If you are, review the prior steps to make sure no mistakes were made.

    Now it should be possible to make an rsync connection to the Cygwin server over SSH. For example, run a command similar to the following from the client computer:

    rsync -r -t /src/ [Cygwin user]@[Cygwin server IP]:/dst/

    This command should copy the contents of the source directory on the client computer ( /src in this example) to the destination directory on the Cygwin server ( /dst in this example) without prompting for a password.

    Running Rsync Daemon (service) in Cygwin
    When running rsync as a daemon, «modules» must be setup on the server which are mapped to a specific directory. Then, rsync clients connect to a specific module. There can be multiple modules setup on a single rsync server. The rsync «module» concept is somewhat similar to the «share» concept in Windows networking.

    Unlike when using rsync over SSH, authentication is NOT based on Cygwin users. Instead, a file containing user/password combinations is used and the configuration file determines which users are allowed to connect to each rsync module.

      Create a file named /etc/rsyncd.conf to be used as the configuration file for the rsync daemon. Refer to man rsyncd.conf for complete details on the contents and syntax of this file. Here is an example file to help get you started:

    use chroot = yes
    max connections = 4
    log file = /var/log/rsyncd.log

    [rsync_test]
    path = /cygdrive/c/rsync_test
    comment = Rsync Test
    auth users = rsync_user
    secrets file = /etc/rsyncd.secrets
    write only = false
    read only = false
    list = true

    This example defines one rsync module named rsync_test that is mapped to the /cygdrive/c/rsync_test directory which equates to C:\rsync_test in Windows terminology. Only one user, rsync_user , is permitted to use this module. Rsync user names and passwords are stored in the /etc/rsyncd.secrets file.

    Note: Make sure the directory referenced in the path exists. Otherwise, attempts to connect to the rsync server will fail.

    Create a file named /etc/rsyncd.secrets to be used as the user/password file for the rsync daemon. This file should contain one user and password per line separated by a colon. Refer to man rsyncd.conf for more details. Here is an example file to help get you started:

    In this example, there is one one user named rsync_user with a password of password .

    Now you must change the permissions on the /etc/rsyncd.secrets file so that «other» has no access. Otherwise, attempts to connect to the rsync server will fail. To change permissions, run the following command on the Cygwin server:

    chmod o-rwx /etc/rsyncd.secrets

    On the Cygwin server, create a new local Windows user under which the rsync service will run. The password should be set to never expire.

    Grant the «Log on as a service» permission to the user that was created in the previous step.

      On the Cygwin server, go into the Windows Control Panel -> Administrative Tools -> Local Security Policy.

    Navigate to Security Settings -> Local Policies -> User Rights Assignment.

    Locate and double-click the «Log on as a service» policy.

    Add the new user that was created, save the changes, and then close the Local Security Policy

    Create the rsync service by running a command similar to the following:

    cygrunsrv -I «Rsync» -p /cygdrive/c/cygwin/bin/rsync.exe -a «—config=/cygdrive/c/cygwin/etc/rsyncd.conf —daemon —no-detach» -f «Rsync daemon service» —user rsyncd —passwd rsyncd_password

    In this example, the service will run under a user account named rsync with a password of rsyncd_password. These parameters should be changed to match the user/password that you created.

    Start the rsync service by running the following command:

    If you wish to run rsync from the client computer without supplying a password manually, the password must be stored in a file. This file can be named anything, but must not have any permissions for «other». To create a file containing the password «password» and then remove permissions for «other», run the following commands on the client computer:

    echo password > /etc/rsync.password
    chmod o-rwx /etc/rsync.password

    Now, you should be able to connect to rsync on the Cygwin server. To test, run a command similar to the following:

    rsync -r -t —password-file=/etc/rsync.password /src/ rsync_user@[Cygwin server IP]::rsync_test/dst/

    This command will copy files in the /src directory on the client computer to the /dst sub-directory within the directory mapped to the rsync_test module on the Cygwin server.

    Note: In the preceding command example, two colons separate the Cygwin server IP address from the module name/path. This notation is used for a connection to an rsync daemon whereas a single colon is used for a connection via SSH.

    File Permissions
    When using an NTFS file system, Cygwin will, by default, apply posix-style file permissions using NTFS file permissions. In some cases this may not be desirable as this can make it difficult to work with the files on the Windows server outside of Cygwin. This behavior can be altered by modifying the /etc/fstab file. Simply add/edit the line in this file to read as follows:

    none /cygdrive cygdrive user,noacl,posix=0 0 0

    The key is this example is the «noacl» parameter.

    Источник

  • Добавить комментарий

    Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Rsync client for windows
  • Rss ридер для windows
  • Rss агрегатор для windows
  • Rss reader для windows phone
  • Rsload windows loader by daz