]> Nutra Git (v1) - gamesguru/git-remote-gcrypt.git/commitdiff
Add support for several cloud storage remotes using rclone
authorBeren Minor <beren.minor+git@gmail.com>
Sat, 14 Apr 2018 17:51:21 +0000 (19:51 +0200)
committerSean Whitton <spwhitton@spwhitton.name>
Sat, 28 Apr 2018 19:46:43 +0000 (12:46 -0700)
rclone is an open-source command-line too to get and put files to several
cloud storage services that aren't supported by rsync.

git-remote-gcrypt can now push encrypted repositories to any configured rclone
remote using gcrypt::rclone://<rclone-repo>:<folder> URLs.

Signed-off-by: Beren Minor <beren.minor+git@gmail.com>
README.rst
git-remote-gcrypt

index 8bcc429a4841e1b754d66076ae103daada3c30b6..21cefc46cffd66b55c7413e2e2b1fc59d7b7234d 100644 (file)
@@ -15,10 +15,10 @@ git-remote-gcrypt is a git remote helper to push and pull from
 repositories encrypted with GnuPG, using a custom format.  This remote
 helper handles URIs prefixed with `gcrypt::`.
 
-Supported backends are `local`, `rsync://` and `sftp://`, where the
-repository is stored as a set of files, or instead any `<giturl>`
-where gcrypt will store the same representation in a git repository,
-bridged over arbitrary git transport.  See "Performance" below for
+Supported backends are `local`, `rsync://` and `sftp://` (and an experimental
+`rclone://` backend), where the repository is stored as a set of files, or
+instead any `<giturl>` where gcrypt will store the same representation in a git
+repository, bridged over arbitrary git transport.  See "Performance" below for
 backends comparison.
 
 The aim is to provide confidential, authenticated git storage and
@@ -119,9 +119,9 @@ Collaboration
     keys of all collaborators and correct participant config.
 
 Dependencies
-    ``rsync`` and ``curl`` for remotes ``rsync:`` and ``sftp:``
-    respectively. The main executable requires a POSIX-compliant shell
-    that supports ``local``.
+    ``rsync``, ``curl`` and ``rclone`` for remotes ``rsync:``, ``sftp:`` and
+    ``rclone:`` respectively. The main executable requires a POSIX-compliant
+    shell that supports ``local``.
 
 GNU Privacy Guard
     Both GPG 1.4 and 2 are supported. You need a personal GPG key. GPG
@@ -149,6 +149,12 @@ rsync URIs
     whereas plain rsync uses either ``user@host:path`` or
     ``rsync://user@host/path``.
 
+rclone URIs
+    The URI format for the rclone backend is the same as rclone URI,
+    ``rclone://<rclone-uri>``, and require to add the corresponding remote
+    in the rclone configuration.
+    Please refer to the rclone documentation for more information.
+
 Repository format
 .................
 
index 8b66f2fbf2a2a89d1e3f2bdcb045d015fc43dd00..d089c571e757a59b2c7963bc6815c4b1ae81cb8c 100755 (executable)
@@ -230,6 +230,9 @@ GET()
        elif isurl rsync "$1"
        then
                (exec 0>&-; rsync -I -W "${1#rsync://}"/"$2" "$3" >&2)
+       elif isurl rclone "$1"
+       then
+               (exec 0>&-; rclone copyto "${1#rclone://}"/"$2" "$3" >&2)
        elif islocalrepo "$1"
        then
                cat "$1/$2" > "$3"
@@ -247,6 +250,9 @@ PUT()
        elif isurl rsync "$1"
        then
                rsync -I -W "$3" "${1#rsync://}"/"$2" >&2
+       elif isurl rclone "$1"
+       then
+               rclone copyto "$3" "${1#rclone://}"/"$2" >&2
        elif islocalrepo "$1"
        then
                cat >| "$1/$2" < "$3"
@@ -258,7 +264,7 @@ PUT()
 # Put all PUT changes for repo $1 at once
 PUT_FINAL()
 {
-       if isurl sftp "$1" || islocalrepo "$1" || isurl rsync "$1"
+       if isurl sftp "$1" || islocalrepo "$1" || isurl rsync "$1" || isurl rclone "$1"
        then
                :
        else
@@ -275,6 +281,9 @@ PUTREPO()
        elif isurl rsync "$1"
        then
                rsync -q -r --exclude='*' "$Localdir/" "${1#rsync://}" >&2
+       elif isurl rclone "$1"
+       then
+               rclone mkdir "${1#rclone://}" >&2
        elif islocalrepo "$1"
        then
                mkdir -p "$1"
@@ -295,6 +304,9 @@ REMOVE()
        then
                xfeed "$2" rsync -I -W -v -r --delete --include-from=- \
                        --exclude='*' "$Localdir"/ "${1#rsync://}/" >&2
+       elif isurl rclone "$1"
+       then
+               xfeed "$2" rclone delete -v --include-from=/dev/stdin "${1#rclone://}/" >&2
        elif islocalrepo "$1"
        then
                for fn_ in $2; do
@@ -309,7 +321,7 @@ REMOVE()
 
 CLEAN_FINAL()
 {
-       if isurl sftp "$1" || islocalrepo "$1" || isurl rsync "$1"
+       if isurl sftp "$1" || islocalrepo "$1" || isurl rsync "$1" || isurl rclone "$1"
        then
                :
        else
@@ -496,13 +508,18 @@ ensure_connected()
                echo_info "Updated URL for $r_name, gitception:// -> ()"
        fi
 
+       if isurl rclone "$URL"; then
+               echo_info "WARNING: git-remote-gcrypt's rclone support is experimental." \
+                       "  Keep backups."
+       fi
+
        # Find the URL fragment
        url_frag=${URL##*"#"}
        isnoteq "$url_frag" "$URL" || url_frag=
        URL=${URL%"#$url_frag"}
 
        # manifestfile -- sha224 hash if we can, else the default location
-       if isurl sftp "$URL" || islocalrepo "$URL" || isurl rsync "$URL"
+       if isurl sftp "$URL" || islocalrepo "$URL" || isurl rsync "$URL" || isurl rclone "$URL"
        then
                # not for gitception
                isnull "$url_frag" ||