rsync4j - Ich möchte rsync in Java berühren.

Vielen Dank. Es ist lustig. Ich möchte rsync für die Entwicklung eines bestimmten Dienstes verwenden. Es ist auch Java. Ich konnte jedoch nichts wie rsync finden, das in Java implementiert ist.

Während der Recherche fand ich Folgendes

https://github.com/fracpete/rsync4j

Überblick

Dieses rsync4j ist ein rsync-Frontend, das unter Windows und Linux ausgeführt wird. In Windows wird rsync ausgeführt, indem die für rsync erforderliche Binärdatei einmal bereitgestellt und ausgeführt wird.

Prüfung

Funktioniert normal, ja
Z:\users\desktop\a>ls
rsync4j-all-3.1.2-12-spring-boot.jar

Z:\users\desktop\a>java -jar rsync4j-all-3.1.2-12-spring-boot.jar
usage: com.github.fracpete.rsync4j.RSync
       [-h] [--output-commandline] [--maxtime MAXTIME] [-v]
       [--info INFO] [--debug DEBUG] [--msgs2stderr] [-q] [--no-motd] [-c]
       [-a] [-r] [-R] [--no-implied-dirs] [-b] [--backup-dir BACKUPDIR]
       [--suffix SUFFIX] [-u] [--inplace] [--append] [--append-verify] [-d]
       [-l] [-L] [--copy-unsafe-links] [--safe-links] [--munge-links] [-k]
       [-K] [-H] [-p] [-E] [--chmod CHMOD] [-X] [-o] [-g] [--devices]
       [--specials] [-t] [-O] [-J] [--super] [--fake-super] [-S]
       [--preallocate] [-n] [-W] [-x] [-B BLOCKSIZE] [-e RSH]
       [--rsync-path RSYNCPATH] [--existing] [--ignore-existing]
       [--remove-source-files] [--delete] [--delete-before]
       [--delete-during] [--delete-delay] [--delete-after]
       [--delete-excluded] [--ignore-missing-args] [--delete-missing-args]
       [--ignore-errors] [--force] [--max-delete MAXDELETE]
       [--max-size MAXSIZE] [--min-size MINSIZE] [--partial]
       [--partial-dir PARTIALDIR] [--delay-updates] [-m] [--numeric-ids]
       [--usermap USERMAP] [--groupmap GROUPMAP] [--chown CHOWN]
       [--timeout TIMEOUT] [--contimeout CONTIMEOUT] [-I] [-M REMOTEOPTION]
       [--size-only] [--modify-window MODIFYWINDOW] [-T TEMPDIR] [-y]
       [--compare-dest COMPAREDEST] [--copy-dest COPYDEST]
       [--link-dest LINKDEST] [-z] [--compress-level COMPRESSLEVEL]
       [--skip-compress SKIPCOMPRESS] [-C] [-f FILTER] [--exclude EXCLUDE]
       [--exclude-from EXCLUDEFROM] [--include INCLUDE]
       [--include-from INCLUDEFROM] [--files-from FILESFROM] [-0] [-s]
       [--address ADDRESS] [--port PORT] [--sockopts SOCKOPTS]
       [--blocking-io] [--stats] [-8] [--human-readable] [--progress] [-i]
       [--out-format OUTFORMAT] [--log-file LOGFILE]
       [--log-file-format LOGFILEFORMAT] [--password-file PASSWORDFILE]
       [--list-only] [--bwlimit BWLIMIT] [--outbuf OUTBUF]
       [--write-batch WRITEBATCH] [--only-write-batch ONLYWRITEBATCH]
       [--read-batch READBATCH] [--protocol PROTOCOL] [--iconv ICONV]
       [--checkum-seed CHECKSUMSEED] [-4] [-6] [--version]
       [--additional ADDITIONAL] src dest
com.github.fracpete.rsync4j.RSync: error: too few arguments

Z:\users\desktop\a>java -jar rsync4j-all-3.1.2-12-spring-boot.jar Z:\users\desktop\a Z:\users\desktop\a\a
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries extractBinaries
Information: Setting up rsync4j environment in 'C:\Users\hani\rsync4j'...
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries extractBinaries
Information: Creating directory: C:\Users\hani\rsync4j\bin
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries extractBinaries
Information: Creating directory: C:\Users\hani\rsync4j\home\hani\.ssh
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries extractBinaries
Information: Copy your public key pairs into: C:\Users\hani\rsync4j\home\hani\.ssh
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/cygcom_err-2.dll' to 'C:\Users\hani\rsync4j\bin\cygcom_err-2.dll'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/cygcrypto-1.0.0.dll' to 'C:\Users\hani\rsync4j\bin\cygcrypto-1.0.0.dll'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/cyggcc_s-seh-1.dll' to 'C:\Users\hani\rsync4j\bin\cyggcc_s-seh-1.dll'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/cyggssapi_krb5-2.dll' to 'C:\Users\hani\rsync4j\bin\cyggssapi_krb5-2.dll'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/cygiconv-2.dll' to 'C:\Users\hani\rsync4j\bin\cygiconv-2.dll'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/cygintl-8.dll' to 'C:\Users\hani\rsync4j\bin\cygintl-8.dll'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/cygk5crypto-3.dll' to 'C:\Users\hani\rsync4j\bin\cygk5crypto-3.dll'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/cygkrb5-3.dll' to 'C:\Users\hani\rsync4j\bin\cygkrb5-3.dll'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/cygkrb5support-0.dll' to 'C:\Users\hani\rsync4j\bin\cygkrb5support-0.dll'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/cygwin1.dll' to 'C:\Users\hani\rsync4j\bin\cygwin1.dll'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/cygz.dll' to 'C:\Users\hani\rsync4j\bin\cygz.dll'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/ssh.exe' to 'C:\Users\hani\rsync4j\bin\ssh.exe'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/rsync.exe' to 'C:\Users\hani\rsync4j\bin\rsync.exe'
9 16, 2018 9:59:32 Uhr com.github.fracpete.rsync4j.core.Binaries copyResourceTo
Information: Copying resource 'com/github/fracpete/rsync4j/windows-x86_64/ssh-keygen.exe' to 'C:\Users\hani\rsync4j\bin\ssh-keygen.exe'
skipping directory a

Z:\users\desktop\a>java -jar rsync4j-all-3.1.2-12-spring-boot.jar -av Z:\users\desktop\a Z:\users\desktop\a\a
sending incremental file list
a/
a/rsync4j-all-3.1.2-12-spring-boot.jar
a/a/

sent 9,556,407 bytes  received 47 bytes  19,112,908.00 bytes/sec
total size is 9,553,886  speedup is 1.00

Z:\users\desktop\a>

Rufen Sie Java an.

Bitte schreibe so auf maven.

<dependency>
    <groupId>com.github.fracpete</groupId>
    <artifactId>rsync4j-all</artifactId>
    <version>3.1.2-12</version>
</dependency>

Beispiel: Weder ist asynchron.

Einstellungsoptionen


 // rsync -av /backupmoto/  /backupsaki/ --delete  --exclude='nozokitai/'
        RSync rsync = new RSync()
                .source("/backupmoto/")
                .destination("/backupsaki/")
                .archive(true).verbose(true).delete(true).exclude("nozokitai/");
        CollectingProcessOutput output = null;
        try {
            output = rsync.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(output.getStdOut());
        System.out.println("Exit code: " + output.getExitCode());
        if (output.getExitCode() > 0)
            System.err.println(output.getStdErr());

        ////

Optionen in ein Array werfen


        //rsync -av /backupmoto/  /backupsaki/ --delete  --exclude='nozokitai/'
        RSync rsync;
        try {
           rsync = new RSync();
           rsync.setOptions(new String[]{"-av", "/backupmoto/", "/backupsaki/", "--delete", "--exclude='nozokitai/"});
            CollectingProcessOutput output = rsync.execute();
            System.out.println(output.getStdOut());
            System.out.println("Exit code: " + output.getExitCode());
            if (output.getExitCode() > 0)
                System.err.println(output.getStdErr());
        } catch (Exception e) {
            e.printStackTrace();
        }

Zusammenfassung

Es wäre schön gewesen, wenn es in Java implementiert worden wäre, aber ich frage mich, ob es in Form der Ausführung einer Binärdatei sein könnte. Wenn ich etwas im tatsächlichen Betrieb herausfinde, möchte ich es zurückgeben.

Ref https://fracpete.github.io/rsync4j/windows/ http://www.atmarkit.co.jp/ait/articles/1702/02/news031.html

Recommended Posts

rsync4j - Ich möchte rsync in Java berühren.
Ich möchte eine E-Mail in Java senden.
Ich möchte so etwas wie "cls" in Java machen
Ich möchte ES2015 auch in Java verwenden! → (´ ・ ω ・ `)
Selbst in Java möchte ich true mit == 1 && a == 2 && a == 3 ausgeben
Ich möchte die if-else-Anweisung für bedingte Verzweigungen in Java vereinfachen
Ich möchte Java-Updates insgesamt stoppen
Ich möchte @Autowired in Servlet verwenden
[Java] Ich möchte mit dem Schlüssel im Objekt eindeutig arbeiten
R von Java ausführen Ich möchte rJava ausführen
Selbst in Java möchte ich true mit == 1 && a == 2 && a == 3 ausgeben (PowerMockito Edition)
Ich möchte Java8 für jeden mit Index verwenden
Ich möchte APP_HOME an Logback in Gradle übergeben
(Beschränkt auf Java 7 oder höher) Ich möchte, dass Sie Objekte in Objects.equals vergleichen
Ich wollte (a == 1 && a == 2 && a == 3) in Java wahr machen
Ich habe versucht, neunundneunzig in Java auszugeben
Ich möchte die IP-Adresse erhalten, wenn ich mit Java eine Verbindung zu Wi-Fi herstelle
Ich möchte irgendwann sogar in Kotlin sein
Ich möchte schnell von Java nach SQLite schreiben
Ich möchte für jedes Array mit Lambda-Ausdruck in Java
Ich habe versucht, Alexa-Fähigkeiten mit Java zu erstellen
[Java Spring MVC] Ich möchte DI in meiner eigenen Klasse verwenden
Ich möchte den Wert in Ruby erhalten
Sogar in Java möchte ich true mit == 1 && a == 2 && a == 3 ausgeben (Javassist zweite Abkochung)
Selbst in Java möchte ich true mit == 1 && a == 2 && a == 3 (Black Magic) ausgeben.
Ich möchte Combine auch in UIKit verwenden.
Ich möchte die praktischen Funktionen von Clojure in Kotlin nutzen
[Java] Ich möchte die Differenz zum Datum berechnen
Ich möchte eine TraceId in das Protokoll einbetten
Ich habe versucht, die Firebase-Push-Benachrichtigung in Java zu implementieren
Ich möchte auch in Laradock Fischschalen verwenden! !!
# 2 [Anmerkung] Ich habe versucht, neunundneunzig mit Java zu berechnen.
Ich möchte ein kleines Symbol in Rails verwenden
Ich habe versucht, eine Clova-Fähigkeit in Java zu erstellen
Ich habe versucht, eine Anmeldefunktion mit Java zu erstellen
Ich möchte eine Funktion in der Rails Console definieren
Ich möchte Bildschirmübergänge mit Kotlin und Java machen!
Ich möchte Schlangenfälle mit Tabellendefinitionen stoppen
Wenn Sie Annotation in Java 8 dynamisch ersetzen möchten
Ich möchte in RSpec auf einen GoogleMap-Pin klicken
Ich habe versucht, die Methode der gegenseitigen Teilung von Eugrid in Java zu implementieren
~ Ich habe jetzt versucht, funktionale Programmierung mit Java zu lernen ~
Ich habe versucht herauszufinden, was sich in Java 9 geändert hat
Ich möchte Zeichen konvertieren ...
Ich habe ein Roulette in Java gemacht.
Ich habe versucht, Metaprogrammierung mit Java
[Android Studio] Ich möchte Einschränkungen für die in EditText [Java] registrierten Werte festlegen.
Ich möchte ein Objekt im CSV-Format mit mehrzeiligem Header und Filter in Java zurückgeben
# 1_JAVA Ich möchte die Indexnummer durch Angabe eines Zeichens in der Zeichenfolge erhalten
[Java] Ich möchte ein Byte-Array in eine Hexadezimalzahl konvertieren
Ich möchte einen relativen Pfad in einer Situation finden, in der Pfad verwendet wird
Ich möchte Java Applet ohne Verwendung einer IDE erstellen
[Anfänger] Ich habe ein Programm zum Verkauf von Kuchen in Java erstellt
Ich möchte mit Ruby (ABC177E) eine schnelle Primfaktorisierung durchführen.
Ich möchte eine Liste mit Kotlin und Java erstellen!
Ich wollte nur eine reaktive Eigenschaft in Java erstellen