Code Monkey home page Code Monkey logo

sync-services's Introduction

sync-services(1)

NAME

sync-services - Sync services between several hosts

SYNOPSIS

sync-services [ options ]

DESCRIPTION

sync-services could be used to synchronized several similar configuration files on multiple hosts. This is mainly useful when administrating a cluster from which configuration files are not globally stored on a filer.

ARGUMENTS

-d DIR, --config-dir DIR

The configuration directory to be used instead of default one which is './.sync-services'.

-c CONF, --config CONF

The configuration file to be used instead of default one which is 'config'.

Note
The configuration file is relative to the configuration directory.
-I, --ips IPS

Space-separated list of IPs to sync instead of all.

-i, --init

Initialize configuration directory and exit.

Note
This option is only run if no configuration directory is found.
-r, --dry-run

Only print what would be done.

-v, --verbose

Run in verbose mode.

-h, --help

Print help screen.

CONFIGURATION FILE

The configuration file is located by default in './.sync-services/config'.

A configuration file must be present for sync-services to run.

The configuration file consists of bash(1) variables which syntax is as simple as:

VARIABLE="VALUE"

General options

ips

This is a space separated list of servers that should be synchronized together.

Note
At this moment only IP addresses should be specified, not hostnames.
Warning
IP addresses of all members from the cluster had to be defined. This means even IP address of current member must be set.
includes

A bash(1) array of all files and/or directories to include during the synchronization process. This options useful when for some application that use configuration files in several paths.

Note

For example, application foo is using '/etc/foo.conf' as the main configuration file and '/etc/foo.d' for some configuration snippets. In addition the '/etc/default/foo' and '/etc/init.d/foo' files should also be synchronized to other hosts. Put sync-services configuration files under '/etc/foo.d' and add in '.sync-services/config':

includes=("/etc/foo.conf" "/etc/default/foo" "/etc/init.d/foo" )

Included files might need to be deleted first on remote host in a post_update_remote_hook (see below).

run_parts

Path to run-parts(8) binary. By default this is hard-coded to $(which run-parts) and shouldn’t be changed.

ssh

Path to ssh(1) binary. By default this is hard-coded to $(which ssh) and shouldn’t be changed.

ssh_opts

Options to be passed to ssh(1).

sync

Command used to synchronize files. The string '@@IP@@' is expanded to the target host ip address.

Note

A very simple and efficient command could be:

rsync --archive -i--relative --stats --delete --progress ${includes[*]} @@IP@@:/

If root connections are forbiden in remote host then following command could be used:

sudo -E rsync --archive --itemize-changes --rsh="ssh ${ssh_opts}" \
--relative --stats --delete --progress --rsync-path "sudo rsync" \
${includes[*]} `id -un`@@@IP@@:/
forbidden_dirs

Regexp defining directories that mustn’t be synchronized. By default '/$|/lib/init/rw|/proc|/sys|/dev|/etc$' to exclude:

  • /

  • /lib/init/rw

  • /proc

  • /sys

  • /dev

  • /etc

Note
This is not a good idea to run sync-services from those directories.

hooks

Hooks can be run ad different moment from the synchronization process:

pre_update_hook

This hook is ran on local host before the synchronization process starts. This hook is generally a good place to generate configuration files from scripts or to restart the service on local host.

post_update_hook

This hook is ran on local host after the synchronization process starts. This is ran when all hosts are synchronized.

pre_update_remote_hook

This hook is ran on remote host before the synchronization process starts for this specific host. This is generally a good place to ask user confirmation before going on on remote host.

Note
This command is run before the synchronization process. Thus files might not be present on remote host.
post_update_remote_hook

This hook is ran on remote host after the synchronization process starts for this specific host. This is generally a good place to restart the service on remote host.

Note

If some files are included using the includes statement the following command could be used in '.sync-services/post-update-remote/10remove-included-files' to move files in target directory

#!/bin/sh
sudo rm -rf /path/to/be/synced

HOW DOES IT WORK

sync-services is designed to be run directly in the directory to be synchronized. The configuration files must be located in the directory that should be synchronized under the '.sync-service' directory.

sync-services looks up for all IP address on localhost that are on a IPv4 global scope and remove all local IP addresses from 'ips' configuration entry (that’s why host names does not work yet).

Then the 'pre_update_hook' is run.

For each IP addresses from 'ips' but local:

  • The 'pre_update_remote_hook' is run on remote host through a ssh(1).

  • The local directory is synchronized to the remote host using command defined in 'sync'.

  • The 'post_update_remote_hook' is run on remote host through a ssh(1).

Then the 'post_update_hook' is run.

SEE ALSO

  • run-parts(8)

  • ssh(1)

  • rsync(1)

  • sudo(1)

HISTORY

2011-06-07
  • Version 1.4.1.

  • Add configuration examples.

2011-05-23
  • Version 1.4.

  • Add '/etc' to exclude directories.

  • Change default 'sync' command.

2011-05-12
  • use '--rsync-path' in rsync instead of tar and ssh.

2011-05-09
  • Version 1.3.

  • Add '--ip' option.

  • fix config generation at init time.

2011-04-26
  • Add support for non-root sync commands using tar(1).

2010-09-21
  • Add include option

  • Prettiest verbose display

2010-09-13
  • First release

BUGS

No time to include bugs, command actions might seldom lead astray user’s assumption.

AUTHORS

sync-services is written by Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>.

Copyright © 2010-2011 Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>.

Relased under WTFPL (http://sam.zoy.org/wtfpl/COPYING).

sync-services's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.