-
Notifications
You must be signed in to change notification settings - Fork 0
/
rMsync.sh
49 lines (41 loc) · 1.24 KB
/
rMsync.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
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# Sync script for the reMarkable reader
# Version: 0.1
# Author: Simon Schilling
# Edit: Xin Zhang
# Licence: MIT
# Remote configuration
RMDIR="/home/root/.local/share/remarkable/xochitl/"
RMUSER="root"
RMIP="10.11.99.1"
SSHPORT="22"
# Local configuration
#---------------------------------------------------------------------#
MAINDIR="/mnt/d/Github/rM2PDF"
BACKUPDIR="$MAINDIR/original_pdf/" # Download all rM contents
OUTPUTDIR="$MAINDIR/noted_pdf/" # PDFs of everything on the rM
TEMPORARYDIR="$MAINDIR/temporary/"
#---------------------------------------------------------------------#
LOG="sync.log" # Log file name in $MAINDIR
LOG="$MAINDIR/$(date +%y%m%d)-$LOG"
echo $'\n' >> $LOG
date >> $LOG
if [ "$RMUSER" ] && [ "$SSHPORT" ]; then
S="ssh -p $SSHPORT -l $RMUSER";
fi
# check for rM
$S $RMIP -q exit
if [ $? == "0" ]; then
# Download all files
echo "BEGIN BACKUP" >> $LOG
mkdir -p "$BACKUPDIR"
echo "scp \"$RMUSER@$RMIP:$RMDIR\" $BACKUPDIR" >> $LOG
scp -r "$RMUSER@$RMIP:\"$RMDIR\"*" "$BACKUPDIR" >> $LOG 2>&1
if [ $? -ne 0 ]; then
ERRORREASON=$ERRORREASON$'\n scp command failed'
ERROR=1
fi
echo "BACKUP END" >> $LOG
mkdir -p "$OUTPUTDIR"
mkdir -p "$TEMPORARYDIR"
fi