Add support for multiple cron jobs within rsync client
This commit is contained in:
parent
8b1010aa02
commit
e9ae9dea8c
@ -19,10 +19,11 @@ Get files from `remote server` to a `data container`:
|
||||
|
||||
### Client setup
|
||||
|
||||
Start client to sync every night at 3AM:
|
||||
Start client to pack and sync every night:
|
||||
|
||||
$ docker run --name=rsync_client -v client_vol_to_sync:/data \
|
||||
-e CRON_TASK="0 3 * * * rsync -e 'ssh -p 2222 -o StrictHostKeyChecking=no' -avz root@foo.bar.com:/data/ /data/" \
|
||||
-e CRON_TASK_1="0 1 * * * /data/pack-db.sh" \
|
||||
-e CRON_TASK_2="0 3 * * * rsync -e 'ssh -p 2222 -o StrictHostKeyChecking=no' -avz root@foo.bar.com:/data/ /data/" \
|
||||
eeacms/rsync client
|
||||
|
||||
Copy the client SSH public key printed found in console
|
||||
|
@ -13,10 +13,16 @@ if [ ! -z "$SSH_AUTH_KEY" ]; then
|
||||
fi
|
||||
|
||||
# Provide CRON_TASK via environment variable
|
||||
if [ ! -z "$CRON_TASK" ]; then
|
||||
echo "$CRON_TASK" > /etc/crontabs/root
|
||||
echo "root" > /etc/crontabs/cron.update
|
||||
fi
|
||||
echo '' > /etc/crontabs/root
|
||||
for item in `env`; do
|
||||
case "$item" in
|
||||
CRON_TASK*)
|
||||
ENVVAR=`echo $item | cut -d \= -f 1`
|
||||
printenv $ENVVAR >> /etc/crontabs/root
|
||||
echo "root" > /etc/crontabs/cron.update
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Generate host SSH keys
|
||||
if [ ! -e /etc/ssh/ssh_host_rsa_key.pub ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user