Pejman Moghadam / Scripts

Bash script - rsync an entire linux system

pibluc domain


#!/bin/bash

# Current Working Directory
CWD="$(readlink -f $(dirname $0))"
cd "$CWD"

rsync --archive --compress --verbose --rsh "ssh -p22 -i ./id_rsa" \
    --exclude="fstab" \
    root@192.168.1.2:/bin \
    :/boot \
    :/dev \
    :/etc \
    :/home \
    :/lib \
    :/media \
    :/mnt \
    :/opt \
    :/root \
    :/sbin \
    :/srv \
    :/tftpboot \
    .

echo
echo /storage
echo

rsync --archive --compress --verbose \
    --exclude="*.iso" \
    --exclude="lost+found" \
    --exclude="*.aria2" \
    --rsh "ssh -p22 -i ./id_rsa" \
    root@192.168.1.2:/storage/ ./storage

echo 
echo /usr
echo

rsync --archive --compress --verbose \
    --exclude="share/*" \
    --exclude="/doc/*" \
    --exclude="*.ok" \
    --exclude="*.loss" \
    --exclude="*.rtt" \
    --rsh "ssh -p22 -i ./id_rsa" \
    root@192.168.1.2:/usr/ ./usr

echo 
echo /var
echo

rsync --archive --compress --verbose \
    --exclude="iso.bin" \
    --exclude="mrtg-3660/*" \
    --exclude="ibs_*" \
    --exclude="download/*" \
    --exclude="*.png" \
    --exclude="*.?" \
    --exclude="*.?.gz" \
    --exclude="snmpd.log" \
    --exclude="bgpd.log" \
    --exclude="*.html" \
    --exclude="access_log*" \
    --exclude="error_log*" \
    --exclude="log/messages" \
    --exclude="log/syslog" \
    --rsh "ssh -p22 -i ./id_rsa" \
    root@192.168.1.2:/var/ ./var

BY: Pejman Moghadam
TAG: rsync
DATE: 2013-02-19 12:38:11


Pejman Moghadam / Scripts [ TXT ]