mirror of
https://github.com/newnius/Dockerfiles.git
synced 2025-06-06 08:11:54 +00:00
add rsync
This commit is contained in:
parent
931c0486a7
commit
d9dc56d632
9
rsync/Dockerfile
Normal file
9
rsync/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
FROM alpine:3.10
|
||||
|
||||
MAINTAINER Newnius <newnius.cn@gmail.com>
|
||||
|
||||
RUN apk add --no-cache rsync
|
||||
|
||||
ADD bootstrap.sh /etc/bootstrap.sh
|
||||
|
||||
ENTRYPOINT ["/etc/bootstrap.sh"]
|
35
rsync/README.md
Normal file
35
rsync/README.md
Normal file
@ -0,0 +1,35 @@
|
||||
# Deploy rsync in docker
|
||||
|
||||
## Deploy
|
||||
|
||||
#### Run as Server
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
--name rsync \
|
||||
-d \
|
||||
--restart always \
|
||||
--cpus 1.0 \
|
||||
--publish 873:873 \
|
||||
--mount type=bind,src=/etc/localtime,dst=/etc/localtime,readonly \
|
||||
--mount type=bind,src=/data/,dst=/data/ \
|
||||
--mount type=bind,src=/data/rsync/config/,dst=/config/ \
|
||||
newnius/rsync
|
||||
```
|
||||
|
||||
#### Run as Client
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
-it \
|
||||
--rm \
|
||||
--cpus 1.0 \
|
||||
--name rsync \
|
||||
--env AUTH_USER=newnius \
|
||||
--env AUTH_PASSWORD=password \
|
||||
--mount type=bind,src=/etc/localtime,dst=/etc/localtime,readonly \
|
||||
--mount type=bind,src=/data/,dst=/data/ \
|
||||
newnius/rsync rsync -avzP --delete --password-file=/etc/rsyncd.secret newnius@192.168.1.101::data/ /data/
|
||||
```
|
||||
|
||||
|
21
rsync/bootstrap.sh
Executable file
21
rsync/bootstrap.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
if ! [[ -z "${AUTH_PASSWORD}" ]]; then
|
||||
echo "$AUTH_PASSWORD" > /etc/rsyncd.secret
|
||||
if ! [[ -z "${AUTH_USER}" ]]; then
|
||||
echo "$AUTH_USER:$AUTH_PASSWORD" > /etc/rsyncd.secrets
|
||||
chmod 600 /etc/rsyncd.secrets
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d /config/ ]; then
|
||||
cp /config/rsync* /etc/
|
||||
fi
|
||||
|
||||
if ! [[ -z $@ ]]; then
|
||||
# use eval because commands likes `key=value command` would cause file not found error when using $@, but this eval will ruin current environment
|
||||
eval $@
|
||||
else
|
||||
rsync --daemon --config=/etc/rsyncd.conf
|
||||
while pgrep rsync > /dev/null; do sleep 1; done
|
||||
fi
|
Loading…
Reference in New Issue
Block a user