diff --git a/vagrant/fs-primary.sh b/vagrant/fs-primary.sh new file mode 100644 index 00000000..ebe52405 --- /dev/null +++ b/vagrant/fs-primary.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +DEBIAN_FRONTEND=noninteractive + +apt-get install -y lsyncd +mkdir /etc/lsyncd + +# STOP. Generate a root ssh key on primary, and provide the public key to the root account on secondary in authorized_keys. + +cp fs-primary/etc/lsyncd/lsyncd.conf.lua /etc/lsyncd/ +# EDIT /etc/lsyncd/lsyncd.conf.lua +cp fs-primary/etc/logrotate.d/lsyncd /etc/logrotate.d/ + +service lsyncd start +#should already exist: sudo update-rc.d lsyncd defaults diff --git a/vagrant/fs-primary/etc/logrotate.d/lsyncd b/vagrant/fs-primary/etc/logrotate.d/lsyncd new file mode 100644 index 00000000..efef6944 --- /dev/null +++ b/vagrant/fs-primary/etc/logrotate.d/lsyncd @@ -0,0 +1,13 @@ +/var/log/lsyncd*.log { + monthly + missingok + rotate 7 + compress + delaycompress + notifempty + su root root + sharedscripts + postrotate + [ -s /run/lsyncd.pid ] && /usr/sbin/service lsyncd restart > /dev/null 2>/dev/null || true + endscript +} diff --git a/vagrant/fs-primary/etc/lsyncd/lsyncd.conf.lua b/vagrant/fs-primary/etc/lsyncd/lsyncd.conf.lua new file mode 100644 index 00000000..1ab9569f --- /dev/null +++ b/vagrant/fs-primary/etc/lsyncd/lsyncd.conf.lua @@ -0,0 +1,26 @@ +-- Inotify listener max needs to be turned up. Assume 2KB per directory watched. +-- The number of mirrored directories is the relevant variable because a Linux watch is created for each directory. +-- It may make more sense to use a SITENAME_FILENAME strategy here instead of directory partitioning. +-- The below example is 10 gigabytes / 2 = number of watches for 10GB, which is 5 million directories. +-- echo 5000000 > /proc/sys/fs/inotify/max_user_watches +-- For /etc/sysctl.conf: fs.inotify.max_user_watches=5000000 +-- Make sure maxProcesses is below ssh's MaxSessions (default is 10) +settings { + logfile = "/var/log/lsyncd.log", + statusFile = "/var/log/lsyncd-status.log", + maxProcesses = 8 +} +sync { + default.rsyncssh, + delete=true, + source="/home/*ACCOUNT*/testone", + host="*HOST*", + targetdir="/home/*ACCOUNT*/testone", + rsync = { + compress = true, + archive = true, + perms = true, + owner = true + }, + delay=0 +}