From b2c075079d12f62f5c95638dfb814e0560edd6e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Radoslav=20Bod=C3=B3?= <bodik@cesnet.cz>
Date: Mon, 25 Mar 2024 15:11:07 +0100
Subject: [PATCH] general: cleanup and documentation

---
 README.md        | 47 +++++++++++++++++++++++++++++++++++++++--------
 rwm.conf.example |  2 --
 rwm.py           |  4 ++--
 3 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/README.md b/README.md
index df6e49d..40b520f 100644
--- a/README.md
+++ b/README.md
@@ -47,38 +47,69 @@ TBD:
 
 
 ## Install
-
 ```
 git clone git@gitlab.flab.cesnet.cz:bodik/rwm.git /opt/rwm
 cd /opt/rwm
-make venv
 make install
 ```
 
+## Development
+```
+git clone git@gitlab.flab.cesnet.cz:bodik/rwm.git /opt/rwm
+cd /opt/rwm
+make install
+make venv
+. venv/bin/activate
+```
 
 ## simple copy: rclone with crypt overlay
 
-* s3 + crypt overlay
+```
+cat > rwm.conf <<__EOF__
+RWM_S3_ENDPOINT_URL: ""
+RWM_S3_ACCESS_KEY: ""
+RWM_S3_SECRET_KEY: ""
+RWM_RCLONE_CRYPT_BUCKET: "rwmcrypt"
+RWM_RCLONE_CRYPT_PASSWORD: ""
+__EOF__
+rwm rclone_crypt sync /data rwmbe:/
+rwm rclone_crypt lsl rwmbe:/
+```
+
+
+## restic: restic backup
 
 ```
-cp rwm.conf.example rwm.conf
-edit rwm.conf
-rwm rcc sync /data rwmbe:/
-rwm rcc lsl rwmbe:/
+cat > rwm.conf <<__EOF__
+RWM_S3_ENDPOINT_URL: ""
+RWM_S3_ACCESS_KEY: ""
+RWM_S3_SECRET_KEY: ""
+RWM_RESTIC_BUCKET: "rwmrestic"
+RWM_RESTIC_PASSWORD: ""
+__EOF__
+rwm restic init
+rwm restic backup /data
+rwm restic snapshots
 ```
 
+
 ### Notes
 
+### Passing arguments
+
+Passthrough full arguments to underlyin tool with "--" (eg. `rwm rclone -- ls --help`).
+
+### rclone sync
 * https://rclone.org/commands/rclone_sync/
 
 It is always the contents of the directory that is synced, not the directory itself.
 So when source:path is a directory, it's the contents of source:path that are copied,
 not the directory name and contents. See extended explanation in the copy command if unsure.
 
+### rclone crypt
 
 * corect, fails to download corrupted files
 ```
-root@bacula-test:/opt/rwm# ./rwm.py rcc copy rwmbe:/testfile.txt .
 2024/03/23 16:54:31 ERROR : testfile.txt: Failed to copy: failed to open source object: not an encrypted file - bad magic string
 2024/03/23 16:54:31 ERROR : Attempt 1/3 failed with 1 errors and: failed to open source object: not an encrypted file - bad magic string
 ```
diff --git a/rwm.conf.example b/rwm.conf.example
index 6413b7d..a31b410 100644
--- a/rwm.conf.example
+++ b/rwm.conf.example
@@ -2,8 +2,6 @@ RWM_S3_ENDPOINT_URL: ""
 RWM_S3_ACCESS_KEY: ""
 RWM_S3_SECRET_KEY: ""
 
-# RWM_RCLONE
-
 RWM_RCLONE_CRYPT_BUCKET: "rwmcrypt"
 RWM_RCLONE_CRYPT_PASSWORD: ""
 
diff --git a/rwm.py b/rwm.py
index fa69a1e..9fa58b2 100755
--- a/rwm.py
+++ b/rwm.py
@@ -153,9 +153,9 @@ def main(argv=None):
 
     parser = ArgumentParser(description="restics3 worm manager")
     parser.add_argument("--config", default="rwm.conf")
-
     subparsers = parser.add_subparsers(title="commands", dest="command", required=False)
-    version_cmd_parser = subparsers.add_parser("version", help="show version")
+
+    subparsers.add_parser("version", help="show version")
     aws_cmd_parser = subparsers.add_parser("aws", help="aws command")
     aws_cmd_parser.add_argument("cmd_args", nargs="*")
     rc_cmd_parser = subparsers.add_parser("rclone", help="rclone command")
-- 
GitLab