Pages

Showing posts with label sync. Show all posts
Showing posts with label sync. Show all posts

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

Sunday, February 6, 2011

rsync and retain root/other_user attributes


~/bin/sync





#!/bin/bash
# add the following line to /etc/sudoers in the remote system
# username ALL = NOPASSWD: /usr/bin/rsync
for myhost in asus dev x30 t60
do
ping -c 1 "$myhost" > /dev/null
if [ "$?" -eq 0 ] ; then
echo "$myhost up"
sudo rsync -Pha --delete --rsync-path="sudo rsync" --ignore-errors ~/common-files $USER@$myhost:
else
echo "$myhost down"
fi
done





--
My Emacs Files At GitHub