Pages

Wednesday, July 6, 2011

Bash script to sync a number of machines from the current one


pass "all" to do the lot from one major node. edit as appropriate.
set SYNCHOSTS if you like or set the defaults as appropriate.





#!/bin/bash

COMMAND=$1

hosts=${SYNCHOSTS};
if [ -z ${hosts} ]; then
hosts=(asus x30 dev t60)
fi

for myhost in "${hosts[@]}";
do
ping -c 1 "$myhost" > /dev/null
if [ "$?" -eq 0 ] ; then
echo "${myhost} up"
if [ "${COMMAND}" = "all" ]; then
rsync -avz --force --exclude ".emacs.d/agent" --exclude ".emacs.d/url" --delete --exclude "auto-save-list" --exclude ".gnuskillfiled" --exclude "*~" --ignore-errors ~/common-files $USER@$myhost:
else
rsync -avz ~/Mail $USER@$myhost:
rsync -avz ~/.org-files $USER@$myhost:
rsync -avz ~/bin $USER@$myhost:
fi
else
echo "$myhost down"
fi
done





--
My Emacs Files At GitHub

No comments:

Post a Comment