|
| 1 | +# Concurrent Sync |
| 2 | +A concurrent sync tool which works similar to `rsync`. It supports syncing given sources with multiple targets |
| 3 | +concurrently. |
| 4 | + |
| 5 | +## Requirements |
| 6 | +Python >= 3.8 is required. (CPython and PyPy are both supported) |
| 7 | + |
| 8 | +## Installation |
| 9 | +Concurrent Sync can be either installed directly via pip: |
| 10 | +```shell |
| 11 | +pip install concurrent-sync |
| 12 | +``` |
| 13 | +Or it can be installed from the source: |
| 14 | +```shell |
| 15 | +git clone https://github.com/simsekhalit/concurrent-sync.git |
| 16 | +python3 -m pip install ./concurrent-sync |
| 17 | +``` |
| 18 | + |
| 19 | +## Manual |
| 20 | +``` |
| 21 | +$ python3 -m csync --help |
| 22 | +usage: csync [-h] [--max-memory MAX_MEMORY] [--target TARGET] SOURCE [SOURCE ...] TARGET |
| 23 | +
|
| 24 | +A concurrent sync tool which works similar to rsync. It supports syncing given sources with multiple targets concurrently. |
| 25 | +
|
| 26 | +positional arguments: |
| 27 | + SOURCE specify source directories/files |
| 28 | + TARGET specify target directory |
| 29 | +
|
| 30 | +optional arguments: |
| 31 | + -h, --help show this help message and exit |
| 32 | + --max-memory MAX_MEMORY |
| 33 | + specify allowed max memory usage as percent |
| 34 | + --target TARGET specify additional target directories |
| 35 | +
|
| 36 | +For more information: https://github.com/simsekhalit/concurrent-sync |
| 37 | +``` |
| 38 | +Concurrent Sync takes one or more source paths and one or more target paths as arguments. |
| 39 | +All the given source paths are synced with each given target path concurrently. |
| 40 | +* Only the missing or changed files are copied from source to target. |
| 41 | +* While checking if a file is changed, its modification time and size are used similar to `rsync`. |
| 42 | +* Trailing slash at the end of the source is interpreted in a similar way to `rsync`. |
| 43 | + |
| 44 | +<br>Following **Examples** section clarifies the working mechanics in a more clear way. |
| 45 | + |
| 46 | +## Examples |
| 47 | +### 1. One source path and one target path are given |
| 48 | + |
| 49 | +#### Source |
| 50 | +``` |
| 51 | +/mnt/Source |
| 52 | +/mnt/Source/File1 |
| 53 | +/mnt/Source/File2 |
| 54 | +/mnt/Source/Folder1 |
| 55 | +/mnt/Source/Folder2 |
| 56 | +/mnt/Source/Folder2/File3 |
| 57 | +``` |
| 58 | + |
| 59 | +#### Target |
| 60 | +``` |
| 61 | +/mnt/Target |
| 62 | +``` |
| 63 | + |
| 64 | +Following command is executed: |
| 65 | +```shell |
| 66 | +python3 -m csync /mnt/Source /mnt/Target |
| 67 | +``` |
| 68 | + |
| 69 | +After the sync is completed, target becomes: |
| 70 | +``` |
| 71 | +/mnt/Target |
| 72 | +/mnt/Target/Source |
| 73 | +/mnt/Target/Source/File1 |
| 74 | +/mnt/Target/Source/File2 |
| 75 | +/mnt/Target/Source/Folder1 |
| 76 | +/mnt/Target/Source/Folder2 |
| 77 | +/mnt/Target/Source/Folder2/File3 |
| 78 | +``` |
| 79 | + |
| 80 | +### 2. Two source paths and one target are given |
| 81 | + |
| 82 | +#### Source 1 |
| 83 | +``` |
| 84 | +/mnt/Source1 |
| 85 | +/mnt/Source1/File1 |
| 86 | +/mnt/Source1/File2 |
| 87 | +``` |
| 88 | + |
| 89 | +#### Source 2 |
| 90 | +``` |
| 91 | +/mnt/Source2 |
| 92 | +/mnt/Source2/File3 |
| 93 | +/mnt/Source2/File4 |
| 94 | +``` |
| 95 | + |
| 96 | +#### Target |
| 97 | +``` |
| 98 | +/mnt/Target |
| 99 | +``` |
| 100 | + |
| 101 | +Following command is executed: |
| 102 | +```shell |
| 103 | +python3 -m csync /mnt/Source1 /mnt/Source2 /mnt/Target |
| 104 | +``` |
| 105 | + |
| 106 | +After the sync is completed, target becomes: |
| 107 | +``` |
| 108 | +/mnt/Target |
| 109 | +/mnt/Target/Source1 |
| 110 | +/mnt/Target/Source1/File1 |
| 111 | +/mnt/Target/Source1/File2 |
| 112 | +/mnt/Target/Source2 |
| 113 | +/mnt/Target/Source2/File3 |
| 114 | +/mnt/Target/Source2/File4 |
| 115 | +``` |
| 116 | + |
| 117 | +### 3. Source with trailing slash and target are given |
| 118 | + |
| 119 | +#### Source |
| 120 | +``` |
| 121 | +/mnt/Source |
| 122 | +/mnt/Source/File1 |
| 123 | +/mnt/Source/File2 |
| 124 | +``` |
| 125 | + |
| 126 | +#### Target |
| 127 | +``` |
| 128 | +/mnt/Target |
| 129 | +``` |
| 130 | + |
| 131 | +Following command is executed: |
| 132 | +```shell |
| 133 | +python3 -m csync /mnt/Source/ /mnt/Target |
| 134 | +``` |
| 135 | + |
| 136 | +After the sync is completed, target becomes: |
| 137 | +``` |
| 138 | +/mnt/Target |
| 139 | +/mnt/Target/File1 |
| 140 | +/mnt/Target/File2 |
| 141 | +``` |
| 142 | + |
| 143 | +### 4. Source and target with common paths |
| 144 | +While syncing subdirectories of source paths with target paths, redundant files/folders are removed. |
| 145 | + |
| 146 | +#### Source |
| 147 | +``` |
| 148 | +/mnt/Source |
| 149 | +/mnt/Source/Folder |
| 150 | +/mnt/Source/Folder/File1 |
| 151 | +/mnt/Source/Folder/File2 |
| 152 | +``` |
| 153 | + |
| 154 | +#### Target |
| 155 | +``` |
| 156 | +/mnt/Target |
| 157 | +/mnt/Target/Source |
| 158 | +/mnt/Target/Source/Folder |
| 159 | +/mnt/Target/Source/Folder/File3 |
| 160 | +``` |
| 161 | + |
| 162 | +Following command is executed: |
| 163 | +```shell |
| 164 | +python3 -m csync /mnt/Source /mnt/Target |
| 165 | +``` |
| 166 | + |
| 167 | +After the sync is completed, target becomes: |
| 168 | +``` |
| 169 | +/mnt/Target |
| 170 | +/mnt/Target/Source |
| 171 | +/mnt/Target/Source/Folder |
| 172 | +/mnt/Target/Source/Folder/File1 |
| 173 | +/mnt/Target/Source/Folder/File2 |
| 174 | +``` |
| 175 | + |
| 176 | +Since `File3` is no longer in the source path it's deleted from the target as well. |
| 177 | + |
| 178 | +### 5. One source path and two target paths are given |
| 179 | + |
| 180 | +#### Source |
| 181 | +``` |
| 182 | +/mnt/Source |
| 183 | +/mnt/Source/File1 |
| 184 | +/mnt/Source/File2 |
| 185 | +``` |
| 186 | + |
| 187 | +#### Target 1 |
| 188 | +``` |
| 189 | +/mnt/Target1 |
| 190 | +``` |
| 191 | + |
| 192 | +#### Target 2 |
| 193 | +``` |
| 194 | +/mnt/Target2 |
| 195 | +``` |
| 196 | + |
| 197 | +Following command is executed: |
| 198 | +```shell |
| 199 | +python3 -m csync /mnt/Source /mnt/Target1 --target /mnt/Target2 |
| 200 | +``` |
| 201 | + |
| 202 | +After the sync is completed, targets become: |
| 203 | + |
| 204 | +#### Target 1 |
| 205 | +``` |
| 206 | +/mnt/Target1 |
| 207 | +/mnt/Target1/Source |
| 208 | +/mnt/Target1/Source/File1 |
| 209 | +/mnt/Target1/Source/File2 |
| 210 | +``` |
| 211 | + |
| 212 | +#### Target 2 |
| 213 | +``` |
| 214 | +/mnt/Target2 |
| 215 | +/mnt/Target2/Source |
| 216 | +/mnt/Target2/Source/File1 |
| 217 | +/mnt/Target2/Source/File2 |
| 218 | +``` |
0 commit comments