Using rsync with exclude/include

I'm running 2 ubuntu 9.10 web servers. I need to integrate the adjustments in between these 2 equipments. The adhering to are the directory sites I've to integrate :

/ usr,/ etc,/ var,/ container,/ sbin,/ lib

I'm making use of rsync like the listed below for duplication :

rsync -avP 192.168.2.100:/usr/ /usr

rsync -avP 192.168.2.100:/etc/ /etc - - - - - - below I'll need to exclude several documents like/ etc/udev/ *,/ etc/hosts,/ etc/hostname, ...

I attempted making use of rsync -avP --exclude '/etc/fstab' 192.168.2.100:/etc/ /etc yet it overwritten whole/ etc directory site

Can any kind of one edit and also offer me rsync to one line command which integrates defined directory sites and also not which are left out?. Required aid!

0
2019-12-02 02:48:18
Source Share
Answers: 3

The adhering to is the rsync command to sync numerous directory sites in one - line and also is benefited me. Please allow me recognize if it is properly to make use of.

This need to be worked on SOURCE system :

rsync -avP --exclude 'udev' --exclude 'hosts' --exclude 'hostname' --exclude 'any-account-under-home' /etc /home /usr /var /lib /bin /sbin 192.168.2.100:/

We can exclude several files/directories from defined directory sites.

If we have a documents with the very same name allow claim 'examination' under/ etc/ and also/ residence and also you intend to exclude this documents just from/ etc, after that positioning a exclude access leaving out 'examination' from all.

0
2019-12-03 05:46:38
Source

You need to make use of something similar to this :

$ sudo rsync "$backup_options" --log-file="$backup_log_file" --include-from="$backup_incl_from_file" --exclude-from="$backup_excl_from_file" "$backup_src_folder" "$backup_dest_folder"

where the message documents $ backup_incl_from_file need to include :

usr/***
etc/***
var/***
bin/***
sbin/***
lib/***
...

and also the message documents $ backup_excl_from_file need to include :

etc/udev/
etc/hosts
etc/hostname
...

In this instance

backup_src_folder="192.168.2.100:/"
backup_dest_folder="192.168.2.101:/"

It is necessary you read the rsync male web page prior to you utilize this instance to fulfill your demands, paying unique focus to the INCLUDE/EXCLUDE PATTERN RULES area.

0
2019-12-03 04:14:12
Source

The exclude pattern is about the resource documents, not the location documents. You are in fact leaving out 192.168.2.100:/etc/etc/fstab, which does not exist.

You need to make use of :

rsync -avP --exclude '/fstab' 192.168.2.100:/etc/ /etc
0
2019-12-03 04:11:01
Source