staging.inyokaproject.org

rsync mit Pause und Überwachung

Status: Ungelöst | Ubuntu-Version: Server 18.04 (Bionic Beaver)
Antworten |

Fohnbit

(Themenstarter)

Anmeldungsdatum:
31. August 2013

Beiträge: 162

Hallo,

ich nutze pCloud auf dem Ubuntu Server ... ob pCloudcc die syncronisierung überhaupt kann?

Die interne Syncronisierung wurde mir auch vom Support empfohlen, aber das möchte ich nicht, denn wenn unabsichtlich ein File lokal oder in der Cloud gelöscht wird, wird es auch auf der anderen Seite gelöscht.

Ich nutze pCloud als reine ein-Weg Sicheung meiner Daten. Kein löschen und falls, soll das geziehlt und manuel erfolgen.

An sich läuft das nun nicht so schlecht.

Ich kopiere meine lokalen Daten in das virtuelle Cloud Laufwerk/Mount. rsync checkt ob sich das File lokal geändert hat und uoploaded auch die Änderung. Die Lösch und Überschreibstrategie muss ich noch genau überlegen.

Aber mit dem Logfile watch beendet rsync nun den kopiervorgang und erst dann stell ich ihn auf Pause!

Fohnbit

(Themenstarter)

Anmeldungsdatum:
31. August 2013

Beiträge: 162

so scheint das nun gut zu laufen. Hab eine bessere Möglichkeit als die letzte Logzeile gefunden. Wenn das Cache zu groß wird, wartet er bis das Logfile geschrieben wird (Anzeichen für das nächste File) und pausiert dann

 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
pid=$(pgrep rsync)
pidNotify=$(pgrep inotifywait)

cacheSize=$(du -sb ~/.pcloud/Cache | cut -f1)
cacheSizeH=$(($cacheSize / 1024 / 1024 / 1024))

#value in GB
cacheLimitH=20
cacheLimit=$(($cacheLimitH * 1024 * 1024 * 1024))

stateRsync=''

# Status of rsync if running
if [ -z "$pid" ]; then
        stateRsync=""
else
        stateRsync=$(ps -q $(pgrep rsync | head -1) -o state --no-headers)
fi

echo "sync pCloud script startet. pCloud cache=$cacheSizeH GB, limit=$cacheLimitH GB, rsync PID´s=$pid, State $stateRsync"
logger -t syncpCloud "sync pCloud script startet. pCloud cache=$cacheSizeH GB, limit=$cacheLimitH GB, rsync PID´s=$pid, State $stateRsync"

# Check if Cash is over limit and pause rsync if running
if [ $cacheSize -gt $cacheLimit ]; then
        if [ -z "$pid" ]; then
                echo "CACHE IS OVER TRESHOLD: Sync not running so doing nothing!"
                logger -t syncpCloud  "CACHE IS OVER TRESHOLD: Sync not running so doing nothing!"
                exit 1
        else
                if [ "$stateRsync" = "T" ]; then
                        echo "CACHE IS OVER TRESHOLD: but rsync is alread in suspend state"
                        exit 1
                elif [ -z "$pidNotify" ]; then # when no inotifywait is running
                        echo "CACHE IS OVER TRESHOLD: rsync is running in state $stateRsync and wait now to complete the current file ..."
                        logger -t syncpCloud "CACHE IS OVER TRESHOLD: rsync is running in state $stateRsync and wait now to complete the current file ..."
                        inotifywait -e delete -e modify -e close_write  /var/log/rsync.log

                        echo "PAUSE NOW SYNC: because the last file has now succesfully copied. PIDs $pid"
                        logger -t syncpCloud "PAUSE NOW SYNC: because the last file has now succesfully copied. PIDs $pid"
                        kill -SIGSTOP $pid
                        exit 1
                fi
        fi
fi

if [ -z "$pid" ]; then
        echo "START NEW SYNC"
        logger -t syncpCloud "START NEW SYNC"
        rsync -ahP --bwlimit=5300 --stats --log-file="/var/log/rsync.log" /media/Daten/ /media/pCloud/Daten
        rsync -ahP --bwlimit=5300 --stats --log-file="/var/log/rsync.log" /media/Multimedia/ /media/pCloud/Multimedia
        rsync -ahP --bwlimit=5300 --stats --log-file="/var/log/rsync.log" /media/Files/ /media/pCloud/Files
else
        if [ "$stateRsync" = "T" ]; then
                echo "RESUME SUSPENDED SYNC with PIDs $pid"
                logger -t syncpCloud "RESUME SUSPENDED SYNC with PIDs $pid"
                kill -SIGCONT $pid
                exit 1
        else
                echo "rsync running fine. Nothing to do"
                logger -t syncpCloud "rsync running fine. Nothing to do"
        fi
fi
Antworten |