Add support for multiple cron jobs within rsync client

This commit is contained in:
Alin Voinea 2016-04-27 11:33:03 +03:00
parent 8b1010aa02
commit e9ae9dea8c
2 changed files with 13 additions and 6 deletions

View File

@ -19,10 +19,11 @@ Get files from `remote server` to a `data container`:
### Client setup ### 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 \ $ 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 eeacms/rsync client
Copy the client SSH public key printed found in console Copy the client SSH public key printed found in console

View File

@ -13,10 +13,16 @@ if [ ! -z "$SSH_AUTH_KEY" ]; then
fi fi
# Provide CRON_TASK via environment variable # Provide CRON_TASK via environment variable
if [ ! -z "$CRON_TASK" ]; then echo '' > /etc/crontabs/root
echo "$CRON_TASK" > /etc/crontabs/root for item in `env`; do
echo "root" > /etc/crontabs/cron.update case "$item" in
fi 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 # Generate host SSH keys
if [ ! -e /etc/ssh/ssh_host_rsa_key.pub ]; then if [ ! -e /etc/ssh/ssh_host_rsa_key.pub ]; then