user_data_migrate check if user folder exist before rsync

master
Florian Charlaix 1 year ago
parent 9ca826794d
commit a09c87ec5c
  1. 9
      scripts/user_data_migrate.py

@ -81,12 +81,19 @@ def main(src_path: str, dest_path: str, src_php: str, dest_php: str, src_remote:
max_users = len(users)
for idx, user in enumerate(users):
src_user_files = f"{src_data}/{user}/files/"
print(f"{'='*20}[{user} ({idx+1}/{max_users})]{'='*20}")
sys_stdout.flush()
# Check if user folder exist
if run_command(["test", "-d", src_user_files], src_remote, ssh_args, check=False).returncode != 0:
print("No files...")
continue
run(["rsync", "-avzPh", "--del",
"-e", f"ssh {' '.join(ssh_args)}",
f"{f'{src_remote}:' if src_remote else ''}{src_data}/{user}/files/",
f"{f'{src_remote}:' if src_remote else ''}{src_user_files}",
f"{f'{dest_remote}:' if dest_remote else ''}{dest_data}/{users[user]['email']}/"],
check=True, stdout=None, stderr=None)

Loading…
Cancel
Save