Add --no-ui flag

This commit is contained in:
2026-10-02 13:09:40 +03:00
parent a013ec6131
commit 1f580ae150
2 changed files with 28 additions and 4 deletions
+24 -1
View File
@@ -43,7 +43,26 @@ chmod +x migrate.sh
```
Data lands under `/mnt/stor0/qnap/<nas-name>/<share-name>/`. Per-share rsync logs are written to
`/mnt/stor0/qnap/_logs/`.
`/mnt/stor0/qnap/_logs/`; script messages go to `_logs/migrate.log` while the dashboard is shown.
### Progress dashboard
On a terminal, one block per QNAP is shown (also with `--jobs N`):
```
qnap1 share Photos 3/12 (copying)
File [##########--------------------] 34% 12.3MB/s
Total [######------------------------] 21% 4.2GB / 20.0GB, 183 files
> Photos/2023/IMG_0042.jpg
```
- `File` is the file currently being copied; `Total` is the current share (sized by a dry-run scan before each share, so large shares pause briefly while "scanning").
- Plain rsync output is used instead with `--dry-run`, `--list-only`, non-terminal output, or when an `smb` entry uses `-` (interactive password prompt).
### Stopping
Ctrl+C (or `kill`) stops all rsync/ssh/smbclient processes, unmounts temporary CIFS/NFS mounts and closes SSH connections.
The SSH method reuses one multiplexed connection per NAS, so a key passphrase is asked only once.
## Options
@@ -55,6 +74,10 @@ Data lands under `/mnt/stor0/qnap/<nas-name>/<share-name>/`. Per-share rsync log
| `--jobs N` | Number of NAS devices to process in parallel (default 1) |
| `--dry-run` | Pass `--dry-run` to rsync, no changes made |
| `--list-only` | Only discover and print shares, don't transfer |
| `--no-ui` | Disable the progress dashboard, use plain rsync output |
QNAP system folders (`@Recycle`, `.@__thumb`, `.system`, snapshots, etc.) are skipped automatically.
Re-running the script is safe/idempotent — rsync only copies new or changed files.
If the files were edited on Windows, strip CRLF line endings on TrueNAS before running:
`sed -i 's/\r$//' migrate.sh generate_ssh_keys.sh nas_list.conf`
+4 -3
View File
@@ -12,7 +12,7 @@
#
# Usage:
# ./migrate.sh [--config FILE] [--dest DIR] [--only NAME] [--jobs N]
# [--dry-run] [--list-only] [-h|--help]
# [--dry-run] [--list-only] [--no-ui] [-h|--help]
#
set -euo pipefail
@@ -24,7 +24,7 @@ ONLY_NAME=""
JOBS=1
DRY_RUN=0
LIST_ONLY=0
NO_UI=0
# QNAP system/internal folders that must never be copied or treated as real shares.
SYSTEM_SHARE_EXCLUDES=(
".system" ".system_trash" ".qsync_trash" ".@__thumb" ".@__thumb_mobile"
@@ -371,6 +371,7 @@ while [ $# -gt 0 ]; do
--jobs) JOBS="$2"; shift 2 ;;
--dry-run) DRY_RUN=1; shift ;;
--list-only) LIST_ONLY=1; shift ;;
--no-ui) NO_UI=1; shift ;;
-h|--help) usage ;;
*) die "unknown argument: $1" ;;
esac
@@ -386,7 +387,7 @@ mkdir -p "$LOG_DIR" "$DEST_ROOT"
log "Starting migration. dest=$DEST_ROOT dry_run=$DRY_RUN list_only=$LIST_ONLY"
# Dashboard needs a terminal, no dry/list run, and no interactive SMB password prompt.
if [ -t 1 ] && [ "$DRY_RUN" -eq 0 ] && [ "$LIST_ONLY" -eq 0 ]; then
if [ -t 1 ] && [ "$NO_UI" -eq 0 ] && [ "$DRY_RUN" -eq 0 ] && [ "$LIST_ONLY" -eq 0 ]; then
ui_ok=1
while IFS= read -r -u 4 line || [ -n "$line" ]; do
line="${line%%#*}"; line="${line//$'\r'/}"