• /etc/rsyncd.conf


    [root@backup ~]# cat /etc/rsyncd.conf
    #Rsync server
    #created by oldboy
    ##rsyncd.conf start##
    uid = rsync
    gid = rsync
    use chroot = no
    max connections = 2000
    timeout = 600
    pid file = /var/run/rsyncd.pid
    lock file = /var/run/rsync.lock
    log file = /var/log/rsyncd.log
    ignore errors
    read only = false
    list = false
    hosts allow = 192.168.31.0/24
    hosts deny =0.0.0.0/32
    auth users = rsync_backup
    secrets file = /etc/rsync.password
    ##################################
    [backup]
    comment = backup server by oldboy
    path = /backup

    [root@backup ~]# rsync --daemon

    [root@backup ~]# echo "rsync --daemon" >>/etc/rc.local
    [root@backup ~]# cat /etc/rc.local
    #!/bin/sh
    #
    # This script will be executed *after* all the other init scripts.
    # You can put your own initialization stuff in here if you don't
    # want to do the full Sys V style init stuff.

    touch /var/lock/subsys/local
    rsync --daemon
    [root@backup ~]#


    [root@backup ~]# ps -ef |grep rsync|grep -v grep
    root 2853 1 0 00:19 ? 00:00:00 rsync --daemon
    [root@backup ~]# netstat -lntup|grep rsync
    tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 2853/rsync
    tcp 0 0 :::873 :::* LISTEN 2853/rsync
    [root@backup ~]# ss -lntup|grep rsync
    tcp LISTEN 0 5 :::873 :::* users:(("rsync",2853,5))
    tcp LISTEN 0 5 *:873 *:* users:(("rsync",2853,3))

    [root@backup ~]# useradd rsync -s /sbin/nologin -M 

    [root@backup ~]# id rsync
    uid=501(rsync) gid=501(rsync) groups=501(rsync)
    [root@backup ~]#

    [root@backup ~]# mkdir /backup
    [root@backup ~]# chown -R rsync /backup/
    [root@backup ~]# ls -ld /backup/
    drwxr-xr-x 2 rsync root 4096 Jun 13 00:26 /backup/
    [root@backup ~]#

    [root@backup ~]# [root@backup ~]# chown -R rsync /backup/

    [root@backup ~]# echo "rsync_backup:oldboy" >/etc/rsync.password
    [root@backup ~]# cat /etc/rsync.password
    rsync_backup:oldboy
    [root@backup ~]#

    [root@backup ~]# ll /etc/rsync.password
    -rw-r--r-- 1 root root 20 Jun 13 00:31 /etc/rsync.password
    [root@backup ~]# chmod 600 /etc/rsync.password
    [root@backup ~]# ll /etc/rsync.password
    -rw------- 1 root root 20 Jun 13 00:31 /etc/rsync.password
    [root@backup ~]#

    客户端

    [root@lamp01 ~]# echo "oldboy" >/etc/rsync.password
    [root@lamp01 ~]# chmod 600 /etc/rsync.password
    [root@lamp01 ~]# ll /etc/rsync.password
    -rw------- 1 root root 7 Jun 13 00:47 /etc/rsync.password

    [root@lamp01 ~]# cat /etc/rsync.password 

    oldboy

    [root@lamp01 ~]# rsync -avz /tmp/ rsync_backup@192.168.31.34::backup --password-file=/etc/rsync.password
    sending incremental file list
    ./
    liweiming/

    sent 103 bytes received 17 bytes 240.00 bytes/sec
    total size is 0 speedup is 0.00
    [root@lamp01 ~]#

  • 相关阅读:
    万网域名API查询
    华为鲲鹏麒麟安装docker
    华为鲲鹏麒麟安装K8S
    tkinter如何实现最大化
    if条件判断失败,执行else之后,直接退出整个程序
    python中函数和方法的区别
    在python的函数中使用批量注释,注意缩进
    golang 运行 sqlite 包时报 gcc 命令不存在
    我的10个开发原则
    shell 下载文件
  • 原文地址:https://www.cnblogs.com/liweiming/p/6995871.html
Copyright © 2020-2023  润新知