A simple rsync server/client Docker image to easily rsync data within Docker volumes
Get files from remote server within a docker volume:
$ docker run --rm -v blobstorage:/data/ mtand/rsync \
rsync -avzx --numeric-ids [email protected]:/var/local/blobs/ /data/
Get files from remote server to a data container:
$ docker run -d --name data -v /data busybox
$ docker run --rm --volumes-from=data mtand/rsync \
rsync -avz [email protected]:/var/local/blobs/ /data/
Start client to pack and sync every night:
$ docker run --name=rsync_client -v client_vol_to_sync:/data \
-e CRON_TASK_1="0 1 * * * /data/pack-db.sh" \
-e CRON_TASK_2="0 3 * * * rsync -e 'ssh -p 2222' -aqx --numeric-ids [email protected]:/data/ /data/" \
mtand/rsync client
Copy the client SSH public key printed found in console
Start server on foo.bar.com
# docker run --name=rsync_server -d -p 2222:22 -v server_vol_to_sync:/data \
-e SSH_AUTH_KEY_1="<SSH KEY FROM rsync_client>" \
-e SSH_AUTH_KEY_n="<SSH KEY FROM rsync_client_n>" \
mtand/rsync server
Add test file on server:
$ docker exec -it rsync_server sh
$ touch /data/test
Bring the file on client:
$ docker exec -it rsync_client sh
$ rsync -e 'ssh -p 2222' -avz [email protected]:/data/ /data/
$ ls -l /data/
Request TCP access to port 2222 to an accessible server of environment of the new installation from the source container host server.
Start rsync client on host from where do you want to migrate data (ex. production).
Infrastructures -> Hosts -> Add Container
Open logs from container, copy the ssh key from the message
Start rsync server on host from where do you want to migrate data (ex. devel). The destination container should be temporarily moved to an accessible server ( if it's not on one ) .
Infrastructures -> Hosts -> Add Container
Within rsync client container from step 1 run:
$ rsync -e 'ssh -p 2222' -avz <SOURCE_DUMP_LOCATION> root@<TARGET_HOST_IP_ON_DEVEL>:<DESTINATION_LOCATION>
Content type
Image
Digest
sha256:234a08135…
Size
9.3 MB
Last updated
15 days ago
docker pull mtand/rsync