Code Snippet

Just another Code Snippet site

[rsync] How-To

Source: eeacms/rsync – Docker Hub

# [Client] generate SSH key for non root user

ssh-keygen -t rsa -b 4096

# [Server] Start rsync server container with auth key for non root user
(data will be stored in local folder : /tmp/rsync_server)

docker run --name=rsync_server -d --rm \
    -p 2222:22 \
    -v /tmp/rsync_server:/data \
    -e SSH_AUTH_KEY_1="ssh-rsa AAAAB......wMn8R3xUw== installer@master" \
    eeacms/rsync server

# [Client] SSH connection to rsync server

ssh -p 2222 root@SERVER_HOST_IP

# [Client] Download files FROM server (to client)

rsync -e 'ssh -p 2222' -avzh root@SERVER_HOST_IP:/data/ /tmp/rsync_client/

# [Client] Send files TO server (from client)

 rsync -e 'ssh -p 2222' -avzh /tmp/rsync_client/ root@SERVER_HOST_IP:/data/

#Rsync options : -avzh

  • -v : verbose
  • -r : copies data recursively (but don’t preserve timestamps and permission while transferring data
  • -a : archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships and timestamps
  • -z : compress file data
  • -h : human-readable, output numbers in a human-readable format

, ,


One thought on “[rsync] How-To

Leave a Reply to OLIVIER COMBE Cancel reply

Your email address will not be published. Required fields are marked *