forked from moritz/migrabrator
fix server migration
This commit is contained in:
parent
02926f92fe
commit
f25103d216
@ -25,8 +25,8 @@ def main(loglevel, source_app, dst_domain, target_server, move_volumes, undeploy
|
||||
if not isinstance(numeric_level, int):
|
||||
raise ValueError('Invalid log level: %s' % loglevel)
|
||||
logging.basicConfig(level=numeric_level)
|
||||
move_app(source_app, target_server, dst_domain, move_volumes, undeploy, run_backup)
|
||||
#copy_files_between_servers('kaputt.cloud', '/var/lib/docker/', 'kollektiv-02.local-it.cloud', '/var/lib/docker')
|
||||
#move_app(source_app, target_server, dst_domain, move_volumes, undeploy, run_backup)
|
||||
#copy_files_between_servers('source.example.com', '/var/lib/docker/', 'target.example.com', '/var/lib/docker')
|
||||
|
||||
|
||||
def move_app(source_app, target_server=False, target_domain=False, move_vols=False, undeploy=False, run_backup=False):
|
||||
@ -62,10 +62,10 @@ def copy_files_between_servers(source_server, source_dir, destination_server, de
|
||||
source_key_file = f'{source_key_dir}/id_ed25519'
|
||||
run_ssh(source_server, f'chmod 600 {source_key_file}')
|
||||
# Add the public key to the authorized hosts of the destination server
|
||||
subprocess.run(['ssh-copy-id', '-i', public_key_path,
|
||||
subprocess.run(['ssh-copy-id', '-f' ,'-i', public_key_path,
|
||||
destination_server], check=True, capture_output=True)
|
||||
# Run rsync over SSH on the source server to copy files to the destination server
|
||||
source_rsync_cmd = f'rsync -az --info=progress2 -e "ssh -i {source_key_file} -o StrictHostKeyChecking=accept-new" {source_dir} {destination_server}:{destination_dir}'
|
||||
source_rsync_cmd = f'rsync -az --delete --info=progress2 -e "ssh -i {source_key_file} -o StrictHostKeyChecking=accept-new" {source_dir} {destination_server}:{destination_dir}'
|
||||
print(source_rsync_cmd)
|
||||
run_ssh(source_server, source_rsync_cmd)
|
||||
# Remove the SSH key pair from the source server
|
||||
|
Loading…
x
Reference in New Issue
Block a user