chevereto-free/sync.sh

31 lines
666 B
Bash
Raw Normal View History

2021-11-20 14:34:06 +00:00
#!/usr/bin/env bash
set -e
2021-11-20 22:49:32 +00:00
SOURCE=/var/www/chevereto-free/
2021-11-20 14:34:06 +00:00
TARGET=/var/www/html/
EXCLUDE="\.git|\.DS_Store|\/docs"
2021-11-20 22:49:32 +00:00
cp "${SOURCE}".gitignore "${TARGET}".gitignore
2021-11-20 14:34:06 +00:00
function sync() {
rsync -r -I -og \
--chown=www-data:www-data \
--info=progress2 \
--filter=':- .gitignore' \
2021-11-20 22:49:32 +00:00
--filter=':- .dockerignore' \
--exclude '.git sync.sh' \
2021-11-20 14:34:06 +00:00
--delete \
2021-11-20 22:49:32 +00:00
$SOURCE $TARGET
2021-11-20 14:34:06 +00:00
}
sync
inotifywait \
--event create \
--event delete \
--event modify \
--event move \
--format "%e %w%f" \
--exclude $EXCLUDE \
--monitor \
--recursive \
$SOURCE |
while read CHANGED; do
sync
done