1

I use openmediavault (OMV is a NAS software from openmediavault.org) and have different shares defined. In one of the shares I have a folder structure like this: (examples)

Subfolder"ABC"/Subsubfolder"SWU"/*.*Files   
Subfolder"ABC"/Subsubfolder"SXY"/*.*Files
Subfolder"ABC"/Subsubfolder"ZWE"/*.*Files   
Subfolder"BCD"/Subsubfolder"SWU"/*.*Files
Subfolder"CDE"/Subsubfolder"ABC"/*.*Files   
Subfolder"TXY"/Subsubfolder"SWU"/*.*Files

and would like to divide this to two diverent shares via rsync from within OMV, but I have problems to get it working with include /exclude. I have limited possibilities to make use from rsync, but have an extra options field in the OMV-Rsync gui to enter a include/exclude statement. OMV

I would like to split it up at the Subfolders, I would like to have the Subfolders starting from "0" to "Sj" as one part an starting with "Sk" to "Z" the other.

I already tried

--exclude={/S[k-z]*/,/[T-z]*/} 

but that doesn't work as desired. A dryrun showed me that for example files within the folder: Zur/S056776/ were also synced What can I do, to do it right?

1

Edited answer to match the edited question

You can try the following exclude pattern. Change directory to above the common folder and modify the pattern from folder to match your actual common folder name.

--exclude={/folder/S[k-z]*/,/folder/[T-z]*/}

I don't know why your attempted pattern does not work (but if you show exactly what directories do not work, I might be able to help you find the problem),

--exclude={/S[k-z]*/,/[T-z]*/}

Edit 2,3 - the NAS server is running a linux operating system

The NAS server is running a linux operating system. I have downloaded openmediavault, OMV, and tested. It is running an ssh server and it is possible to run rsync both to transfer files between your computer and the server and to login remotely to the server via ssh and run rsync internally in the server.

  • Login info unless you have changed it

Web interface

User: admin
Password: openmediavault

Client (SSH, console)

User: root
Password: <The password that you have set during installation>
  • Open a terminal window and connect via ssh

    ssh root@ip-address-to-your-server
    # example: ssh root@192.168.0.10  # if local
    
  • Log in or use key authentication to run rsync in the server

  • Run commands in the server

    cd 'path-to-directory-above-folder'
    
    mkdir target1  # only once, or use a target above your current directory
    mkdir target2  #               -"-
    
    rsync -Havn --exclude={/target*/,/folder/S[k-z]*/,/folder/[T-z]*/} * target1
    rsync -Havn --exclude={/target*/,/folder/[0-R]*/,/folder/S[0-j]*/} * target2
    
  • You can run some other commands to see that everything is fine, for example

    for i in $(find folder);do test -e "${i/folder/target1\/folder}" || test -e "${i/folder/target2\/folder}" || echo "$i not copied";done
    
  • Log out from the server when done (in my case from the user myself and from root) with

    exit
    

    enter image description here

Original answer

I am not sure, but I think the following command lines will create what you want.

In a test directory I created the subdirectories target1, target2 and folder, and in folder several subdirectories and files for testing.

rsync -Havn --exclude={/target*/,/folder/S[k-z]*/,/folder/[T-z]*/} * target1

rsync -Havn --exclude={/target*/,/folder/[0-R]*/,/folder/S[0-j]*/} * target2
  • First run them with the option -n (as they are here) 'dry run', to check what they will do,
  • then, (maybe after modifications) when they do what you want, remove -n and let rsync copy the directory structure to the target directories.

I tested with the following directory tree:

$ find |sort
.
./folder
./folder/ABC
./folder/ABC/SWU
./folder/ABC/SWU/file
./folder/ABC/SXY
./folder/ABC/SXY/file
./folder/ABC/ZWE
./folder/ABC/ZWE/file
./folder/AIB
./folder/AIB/Sja
./folder/AIB/Sja/file
./folder/AIB/Skb
./folder/AIB/Skb/file
./folder/AIB/SWU
./folder/AIB/SWU/file
./folder/BCD
./folder/BCD/SWU
./folder/BCD/SWU/file
./folder/CDE
./folder/CDE/SWU
./folder/CDE/SWU/file
./folder/Sja
./folder/Sja/Skb
./folder/Sja/Skb/file
./folder/Sja/SWU
./folder/Sja/SWU/file
./folder/Skb
./folder/Skb/Sja
./folder/Skb/Sja/file
./folder/Skb/SWU
./folder/Skb/SWU/file
./folder/TXX
./folder/TXX/Sja
./folder/TXX/Sja/file
./folder/TXX/Sjb
./folder/TXX/Sjb/file
./folder/TXX/Skb
./folder/TXX/Skb/file
./folder/TXY
./folder/TXY/SWU
./folder/TXY/SWU/file
./folder/Zab
./folder/Zab/ABC
./folder/Zab/ABC/file
./folder/zBC
./folder/zBC/ABC
./folder/zBC/ABC/file
./folder/zBC/ABC/target
./folder/zBC/target
./target1
./target2

with the following 'dry runs'

$ rsync -Havn --exclude={/target*/,/folder/S[k-z]*/,/folder/[T-z]*/} * target1
sending incremental file list
folder/
folder/ABC/
folder/ABC/SWU/
folder/ABC/SWU/file
folder/ABC/SXY/
folder/ABC/SXY/file
folder/ABC/ZWE/
folder/ABC/ZWE/file
folder/AIB/
folder/AIB/SWU/
folder/AIB/SWU/file
folder/AIB/Sja/
folder/AIB/Sja/file
folder/AIB/Skb/
folder/AIB/Skb/file
folder/BCD/
folder/BCD/SWU/
folder/BCD/SWU/file
folder/CDE/
folder/CDE/SWU/
folder/CDE/SWU/file
folder/Sja/
folder/Sja/SWU/
folder/Sja/SWU/file
folder/Sja/Skb/
folder/Sja/Skb/file

sent 742 bytes  received 106 bytes  1,696.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)

and

$ rsync -Havn --exclude={/target*/,/folder/[0-R]*/,/folder/S[0-j]*/} * target2
sending incremental file list
folder/
folder/Skb/
folder/Skb/SWU/
folder/Skb/SWU/file
folder/Skb/Sja/
folder/Skb/Sja/file
folder/TXX/
folder/TXX/Sja/
folder/TXX/Sja/file
folder/TXX/Sjb/
folder/TXX/Sjb/file
folder/TXX/Skb/
folder/TXX/Skb/file
folder/TXY/
folder/TXY/SWU/
folder/TXY/SWU/file
folder/Zab/
folder/Zab/ABC/
folder/Zab/ABC/file
folder/zBC/
folder/zBC/ABC/
folder/zBC/ABC/file
folder/zBC/ABC/target/
folder/zBC/target/

sent 713 bytes  received 100 bytes  1,626.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)
5
  • Thanks, looks great. I tried it without the starting folder, and I think I cant make use of "target" cause of using rsync from within Openmediavault so I tried with: ´--exclude={/S[k-z]*/,/[T-z]*/}´ and that doesn't work, cause subfolder matched the pattern. Dec 15 '18 at 20:21
  • @rsyncbeginner, Please describe the directory tree, seen when you are in the folder, where you want to run your command line. You can run find |sort or if there is too much output find -maxdepth 2 |sort and edit your original question to show the result. Indent each line 4 spaces to render the output as 'code'. -- I don't know Openmediavault. Please describe it.
    – sudodus
    Dec 15 '18 at 20:37
  • Thanks for you help! I tried my very best to describe my problem better! Dec 15 '18 at 21:24
  • @rsyncbeginner, 1. I edited the answer. Please try again with the exclude pattern that I suggested if you can change directory (or change the directory structure to get above the common folder folder). 2. Is the NAS server running a linux operating system? In that case, I would guess it is running some ssh server and it should be possible to run rsync both to transfer files between your computer and the server and to login remotely to the server via ssh and run rsync internally in the server.
    – sudodus
    Dec 15 '18 at 23:50
  • @rsyncbeginner, Congratulations, I'm glad that it works now :-)
    – sudodus
    Dec 18 '18 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.