Synchronizing data using Rsync (by quqi99)

Source: Internet
Author: User
Tags rsync
Author: Zhang Hua published in: 2015-12-28
Copyright NOTICE: You can reprint, reprint, please be sure to hyperlink form to indicate the original source and author information and this copyright notice
(http://blog.csdn.net/quqi99)

It is urgent to use rsync to sync photos on multiple machines at home.

sudo apt-get install rsync
sudo update-rc.d-f rsync remove
sudo update-rc.d rsync start 20 2 3 4 5. Stop 20 0 1 6.
sudo update-rc.d rsync enable
hua@node1:~$ sudo sysv-rc-conf--list rsync
rsync 0:off 1:off 2:on 3:on 4:on 5:on 6:off


This is the time to synchronize the directory on a machine (rsync server running on the QNAP, unified on the QNAP modified, rsync client running the following commands to the clients of the folder and server synchronization, to the service end ):

Rsync-avzur--progress--delete/bak/tmp/qnap//qnap/

Rsync-avzur--progress--delete--password-file=/etc/rsync.secret/bak/tmp/qnap//qnap/


To synchronize directories on multiple machines:

Rsync-rave "Ssh-p 22-l hua"-avzur--progress--delete 192.168.99.124:/qnap//qnap/
Equivalent to: Rsync-avzur--progress--delete hua@192.168.99.124:/qnap//qnap/


You can also configure the use of:: Qnap to use the [QNAP] module in the following configuration file/etc/rsyncd.conf:

sudo rsync-avrzp hua@192.168.99.124:: Qnap QNAP

hua@node1:~$ sudo rsync--list-only hua@192.168.99.124::
++++++++++++++++++++++++++++++++++++++++++++++
Welcome to use Quqi rsync services!
++++++++++++++++++++++++++++++++++++++++++++++

QNAP This is QNAP backup data


The steps for configuring the [QNAP] module are as follows:

sudo touch/etc/rsyncd.conf
sudo touch/etc/rsyncd.motd
hua@node1:~$ sudo cat/etc/rsyncd.motd
++++++++++++++++++++++++++++++++++++++++++++++
Welcome to use Quqi rsync services!
++++++++++++++++++++++++++++++++++++++++++++++
sudo touch/etc/rsyncd.secrets
hua@node1:~$ sudo cat/etc/rsyncd.secrets
Hua:passw0rd
sudo chmod 600/etc/rsyncd.secrets
sudo chown root:root/etc/rsyncd.secrets
hua@node1:~$ sudo cat/etc/default/rsync |grep ' rsync_enable '
Rsync_enable=true

Sudo/etc/init.d/rsync restart
sudo iptables-a input-p tcp-m State--state new-m TCP--dport 873-j
Vi/etc/rsyncd.conf
PID file =/var/run/rsyncd.pid
Port = 873
Address = 192.168.99.124
#usermod-G Root Hua
UID = Hua
GID = root
Use chroot = yes
Read Only = yes
Hosts allow=192.168.99.0/255.255.255.0 10.0.1.0/255.255.255.0
Hosts deny=*
Max connections = 5
MOTD file =/ETC/RSYNCD.MOTD
Log file =/var/log/rsync.log
#transfer logging = yes
Log format =%t%a%m%f%b
Syslog facility = Local3
Timeout = 300

[QNAP]

Path =/qnap
List=yes # You can use the rsync--list-only hua@192.168.99.124:: Commands to list directories
Ignore errors
Auth users = Hua,root
Secrets file =/etc/rsyncd.secrets
Comment = This is QNAP backup data
Exclude = tmp/test/


Finally, I actually do this, I have a qnap, a desktop, a notebook, for some photos of what you want to save a few more than one machine that day broken lost.

1, due to iSCSI on a bug, a client on the QNAP iSCSI server after writing, can not be updated in real time on the other client (must first umount to mount again before), And Qnap iSCSI is stored with a large virtual file, which is not what I want. So the last use of NFS on the QNAP is to store the photos in one copy .

2, the desktop because the IP fixed boot automatically mount (sudo mount-t nfs-o vers=3 192.168.99.122:/public/bak/qnap), and directly copied a copy to the/BAK/QNAP_ The local directory prevents rsync from operating errors from destroying data.

3, the notebook because of frequent outgoing IP is not fixed, out of the use of the contents of the/bak/qnap_local directory, the need to sync at home manual synchronization:

sudo mount-t nfs-o vers=3 192.168.99.122:/public/bak/qnap
CD ~ && rsync-avzurp--exclude ' doc '--exclude ' photo '--exclude ' media '--progress--delete/bak/qnap/ P_local

4, usually Home Office unified from the desktop to write/bak/qnap directory to write the data directly to the QNAP. Mobile devices such as mobile phones access data via QNAP FTP.


20171031 Update :

The final programme is:

1, use autos to first share the NFS shared directory on the NAS to the Desktop (Note: NFS Total directory cannot use inotify):

hua@node1:~$ grep-r ' Auto.direct '/etc/auto.master
/-Auto.direct--timeout 60
hua@node1:~$ Cat/etc/auto.direct
/nas-fstype=nfs4,rsize=32768,wsize=32768 192.168.99.122:/public

2, and then manually run the following two commands directly:

Rsync-avztur--progress--delete/nas/doc//bak/doc
Rsync-avztur--progress--delete/nas/photo//bak/photo



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.