-
Notifications
You must be signed in to change notification settings - Fork 0
/
keesync.sh
executable file
·39 lines (31 loc) · 1.44 KB
/
keesync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
a="$(ssh 192.168.31.74 -l Jinglei stat --format=%X /Share/Jinglei/Database.kdbx)"
b="$(stat --format=%X /home/archer/Documents/Database.kdbx)"
c="$(ssh 192.168.31.74 -l Jinglei stat --format=%s /Share/Jinglei/Database.kdbx)"
d="$(stat --format=%s /home/archer/Documents/Database.kdbx)"
if [ $c == $d ]
then
echo "Everything up-to-date!" > /dev/pts/0
else
date >> /home/archer/CronScripts/keesync.log
echo "remote : $a" >> /home/archer/CronScripts/keesync.log
echo "local : $b" >> /home/archer/CronScripts/keesync.log
if [ $a -gt $b ]
then
echo "Syncing remote -> local" > /dev/pts/0
echo "Syncing remote -> local" >> /home/archer/CronScripts/keesync.log
rsync -av -e "ssh -p 22" [email protected]:/Share/Jinglei/Database.kdbx /home/archer/Documents/Database.kdbx >> /home/archer/CronScripts/keesync.log
cd /home/archer/Documents
git add Database.kdbx
git commit -m "Update Database.kdbx"
git push >> /home/archer/CronScripts/keesync.log
else
echo "Syncing local -> remote" > /dev/pts/0
echo "Syncing local -> remote" >> /home/archer/CronScripts/keesync.log
rsync -av -e "ssh -p 22" /home/archer/Documents/Database.kdbx [email protected]:/Share/Jinglei/Database.kdbx >> /home/archer/CronScripts/keesync.log
fi
echo "Sync Finished!" > /dev/pts/0
echo >> /home/archer/CronScripts/keesync.log
echo "------------------------------" >> /home/archer/CronScripts/keesync.log
echo >> /home/archer/CronScripts/keesync.log
fi