NSAS Wiki

Network System Access Solutions

User Tools

Site Tools


linux:sync-system

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

linux:sync-system [2017/05/04 15:23] (current)
michel.pelzer created
Line 1: Line 1:
 +<file bash /​usr/​local/​bin/​sync-system.sh>​
 +#!/bin/bash
  
 +if [ $# -lt 1 ]
 +then
 + HOST=$@
 + HOST=${HOST:​=fw-b fw-c}
 +else
 + HOST=$@
 +fi
 +function check (){
 +RESULT=$?
 +RESULT=${RESULT:​=99}
 +if [ ${RESULT} = "​99"​ ] || [ ${RESULT} -gt 0 ]
 +then
 + echo -e " -> Folder: ${folder} ​ \t failed"​
 +#else
 +# echo done
 +fi
 +}
 +
 +echo -e "​Starting System synchronisation"​
 +COMMAND="​rsync -aHlp --delete --inplace"​
 +for host in ${HOST}
 +do
 + echo -en " localhost -> ${host}"​
 + for folder in bin boot etc home lib lib64 root sbin srv usr var
 + do
 + cd /
 + #echo -en " -> Folder: ${folder} ​ \t"
 + case ${folder} in
 + etc)
 + ${COMMAND} \
 + --exclude etc/fstab \
 + --exclude etc/mtab \
 + --exclude etc/​hostname \
 + --exclude etc/motd \
 + --exclude etc/​motd.tail \
 + --exclude etc/issue \
 + --exclude etc/​issue.net \
 + --exclude etc/hosts \
 + ${folder} ${host}:​$(pwd)/​ 2>/​dev/​null
 + ;;
 + var)
 + ${COMMAND} \
 + --exclude var/log \
 + --exclude var/run \
 + ${folder} ${host}:​$(pwd)/​ 2>/​dev/​null
 + ;;
 + root)
 + ${COMMAND} \
 + --exclude root/​.zsh_history \
 + ${folder} ${host}:​$(pwd)/​ 2>/​dev/​null
 + ;;
 + *)
 + ${COMMAND} ${folder} ${host}:​$(pwd) 2>/​dev/​null
 + ;;
 + esac
 + check
 + done
 + RESULT=$?
 + RESULT=${RESULT:​=99}
 + if [ ${RESULT} = "​99" ​ ] || [ ${RESULT} -gt 0  ]
 + then
 + echo -e "\t failed"​
 + else
 + echo -e "\t done"
 + fi
 +done
 +</​file>​
linux/sync-system.txt ยท Last modified: 2017/05/04 15:23 by michel.pelzer