From 60d25124c4d42a342168d993e6670c18dc03a514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Sainl=C3=A9ger?= Date: Mon, 2 Feb 2026 21:59:14 +0100 Subject: [PATCH] [IMP] use rsync instead of cp for filestore copy Replace mkdir + rm -rf + cp -a sequence with rsync --delete: Before (3 commands): sudo mkdir -p "$dst_path" sudo rm -rf "$dst_path" sudo cp -a "$src_path" "$dst_path" After (2 commands): sudo mkdir -p "$(dirname "$dst_path")" sudo rsync -a --delete "${src_path}/" "${dst_path}/" Benefits: - Incremental copy: only transfers changed files on re-run - Atomic delete + copy: --delete removes extra files in destination - Preserves all attributes like cp -a - Faster for large filestores when re-running migration Added rsync to required commands check. --- lib/common.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index deead8d..4329eea 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -11,7 +11,7 @@ readonly FILESTORE_SUBPATH="var/lib/odoo/filestore" check_required_commands() { local missing=() - for cmd in docker compose sudo; do + for cmd in docker compose sudo rsync; do if ! command -v "$cmd" &>/dev/null; then missing+=("$cmd") fi @@ -62,9 +62,8 @@ copy_filestore() { local src_path="${DATASTORE_PATH}/${from_service}/${FILESTORE_SUBPATH}/${from_db}" local dst_path="${DATASTORE_PATH}/${to_service}/${FILESTORE_SUBPATH}/${to_db}" - sudo mkdir -p "$dst_path" - sudo rm -rf "$dst_path" - sudo cp -a "$src_path" "$dst_path" + sudo mkdir -p "$(dirname "$dst_path")" + sudo rsync -a --delete "${src_path}/" "${dst_path}/" echo "Filestore ${from_service}/${from_db} copied to ${to_service}/${to_db}." }