unused: unison synchronizer

This commit is contained in:
Ferit Yiğit BALABAN 2023-05-25 07:38:32 +03:00
parent 600f6e3a08
commit 5aa4ecffc9
Signed by: fyb
GPG Key ID: E21FEB2C244CB7EB

32
deprecated/unison_sync.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
#
# Ferit Yiğit BALABAN <fybalaban@fybx.dev>, 2023
# & ChatGPT
#
LOCAL_DIR="$HOME/mounts/31_shoka"
REMOTE_DIR="ssh://fyb@192.168.0.3//mnt/shoka"
LOG_FILE="$HOME/navi.log"
UNISON="/usr/bin/unison"
# Run Unison to synchronize the directories
$UNISON $LOCAL_DIR $REMOTE_DIR -batch -auto -confirmbigdel > /dev/null 2>&1
# Check the exit code of Unison
if [ $? -eq 0 ]; then
# Synchronization was successful, log the message and exit
echo "$(date -Iseconds) INFO: unison, sync successful" >> $LOG_FILE
exit 0
else
# Synchronization failed, check if there were conflicts
CONFLICTS=`grep "Conflicting file" /var/log/unison.log | wc -l`
if [ $CONFLICTS -eq 0 ]; then
# There were no conflicts, log the message and exit
echo "$(date -Iseconds) INFO: unison, no diff" >> $LOG_FILE
exit 0
else
# There were conflicts, log the message and exit with an error code
echo "$(date -Iseconds) ERROR: unison, sync conflict" >> $LOG_FILE
exit 1
fi
fi