---
description: rsync & inotify
---

# 20190515

![架構](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LeuD27aoTPQqhWvV-XX%2F-LeuF4p8LH5EpWN5SGpW%2Fimage.png?alt=media\&token=60dffaab-b757-4bb5-befc-c5af28b29ef3)

\[server]

```
# yum install rsync -y
# cat /etc/rsyncd.conf
# cat /etc/rsyncd.pass
# mkdir /data/nextcloud
# systemctl restart rsync
```

![rsyncd.conf](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LeuD27aoTPQqhWvV-XX%2F-LeuGoYSebC5y4OJiRO5%2Fimage.png?alt=media\&token=d80b467e-898d-4a85-b30d-ba5d48c6b450)

![rsyncd.pass](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LeuD27aoTPQqhWvV-XX%2F-LeuHFyZ_yaY_7FmexnS%2Fimage.png?alt=media\&token=ddeb5dfd-eac1-4c57-bd27-ef3df5a3933a)

\[client]

```
# yum install rsync -y
# cat /etc/rsyncd.pass
# mkdir /data/192.168.56.103/
# getenforce
# rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd.pass backup@192.168.56.103::nextcloud /data/192.168.56.103
```

\[server]&\[client]

需要注意的是防火牆有無關閉

```
# systemctl stop firewalld
```

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LeuD27aoTPQqhWvV-XX%2F-LeuILh2-dYLKhcebpkc%2Fimage.png?alt=media\&token=d84b2d26-020b-41d1-a037-c0c9418c8148)

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LeuD27aoTPQqhWvV-XX%2F-LeuJsb3yCgggEsqZFiX%2Fimage.png?alt=media\&token=e1ca2f29-6168-4ff5-91d3-0215d6c9c8eb)

![client拉資料備份](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LeuD27aoTPQqhWvV-XX%2F-LeuLV4hisnsxM_gmrrL%2Fimage.png?alt=media\&token=de9a6dca-89fb-4453-9c8b-a29c43a72290)

\[server]

```
# wget http://jensd.be/download/inotify-tools-3.14.tar.gz
# tar -xvzf inotify-tools-3.14. tar.gz
# cd /inotify-tools-3.14. tar.gz
./configure
make
makeinstall
```

![server端上傳資料](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LeuD27aoTPQqhWvV-XX%2F-LeuNXYSLd18gnfEdhcb%2Fimage.png?alt=media\&token=b4e36a40-d5c7-4064-8997-7bac0a75c88a)

\[server]

```
# ssh-keygen
# cd .ssh/
# scp id_rsa.pub user@192.168.56.101:/tmp/authorized_keys

# ssh root@192.168.56.101
# rsync -avz /data/nextcloud root@192.168.56.101:/data/192.168.56.103
# cd 
# gedit rsync.sh
# chmod +x /rsync.sh
./rsync.sh
```

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LeuD27aoTPQqhWvV-XX%2F-LeuOK7Yl1SvUvAwrq1E%2Fimage.png?alt=media\&token=ec8d30a5-dd8a-4f29-867f-2ce275ff16a2)

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LeuD27aoTPQqhWvV-XX%2F-LeuPCxiyYm8pEnvLCiX%2Fimage.png?alt=media\&token=3a097e81-98c1-4226-9d29-ce1e09176f41)

\[client]

```
# cd .ssh/
# cp /tmp/authorized_keys .
```

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LeuD27aoTPQqhWvV-XX%2F-LeuOv9sx8p1tI0ahnnX%2Fimage.png?alt=media\&token=99adfa38-3a2b-4346-9ca5-2bcf6b4b425a)

![](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LeuD27aoTPQqhWvV-XX%2F-LeuQhSiLBDKrhN9-Utw%2Fimage.png?alt=media\&token=7a9ced5b-0b9f-4273-bfcd-a69b42b6aa3a)

![自動備份](https://1005948644-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LZgzp55XQBZ7U2SrFtZ%2F-LeuD27aoTPQqhWvV-XX%2F-LeuEpz1qDmPyKKdkJmB%2Fimage.png?alt=media\&token=6aa80168-45f7-4423-a339-c3f1fbf11072)

