add rrsync option to enforce `--ignore-existing` (#461)
authordogvisor <13217529+dogvisor@users.noreply.github.com>
Thu, 30 Mar 2023 19:55:56 +0000 (21:55 +0200)
committerGitHub <noreply@github.com>
Thu, 30 Mar 2023 19:55:56 +0000 (12:55 -0700)
The `-no-overwrite` rrsync option disallows the updating of existing files for incoming rrsync copies.

support/rrsync
support/rrsync.1.md

index 94c85f597107186f4bc3b699f9716a72bfa6712c..4b4b87c55c9f89d6779179d035be12aa1e1f7ae8 100755 (executable)
@@ -258,6 +258,9 @@ def main():
 
     if args.munge:
         rsync_opts.append('--munge-links')
+    
+    if args.no_overwrite:
+      rsync_opts.append('--ignore-existing')
 
     if not rsync_args:
         rsync_args = [ '.' ]
@@ -364,6 +367,7 @@ if __name__ == '__main__':
     arg_parser.add_argument('-munge', action='store_true', help="Enable rsync's --munge-links on the server side.")
     arg_parser.add_argument('-no-del', action='store_true', help="Disable rsync's --delete* and --remove* options.")
     arg_parser.add_argument('-no-lock', action='store_true', help="Avoid the single-run (per-user) lock check.")
+    arg_parser.add_argument('-no-overwrite', action='store_true', help="Prevent overwriting existing files by enforcing --ignore-existing")
     arg_parser.add_argument('-help', '-h', action='help', help="Output this help message and exit.")
     arg_parser.add_argument('dir', metavar='DIR', help="The restricted directory to use.")
     args = arg_parser.parse_args()
index 98f2cab0572d978c93bfe70ec452313a21245346..24892900de0434574532cc6f72b4fdba73e39176 100644 (file)
@@ -5,7 +5,7 @@ rrsync - a script to setup restricted rsync users via ssh logins
 ## SYNOPSIS
 
 ```
-rrsync [-ro|-rw] [-munge] [-no-del] [-no-lock] DIR
+rrsync [-ro|-rw] [-munge] [-no-del] [-no-lock] [-no-overwrite]  DIR
 ```
 
 The single non-option argument specifies the restricted _DIR_ to use. It can be
@@ -85,6 +85,11 @@ The remainder of this manpage is dedicated to using the rrsync script.
 
     Avoid the single-run (per-user) lock check.  Useful with [`-munge`](#opt).
 
+0.  `-no-overwrite`
+
+    Enforce `--ignore-existing` on the server. Prevents overwriting existing
+    files when the server is the receiver.
+
 0.  `-help`, `-h`
 
     Output this help message and exit.