I'm running 2 ubuntu 9.10 servers. I have to synchronize the changes between these two machines. The following are the directories I've to synchronize:
/usr, /etc, /var, /bin, /sbin, /lib
I'm using rsync like the below for replication:
rsync -avP 192.168.2.100:/usr/ /usr
rsync -avP 192.168.2.100:/etc/ /etc
------here I'll have to exclude many files like /etc/udev/*, /etc/hosts, /etc/hostname,...
I tried using rsync -avP --exclude '/etc/fstab' 192.168.2.100:/etc/ /etc
but it overwritten entire /etc directory
Can any one edit and give me rsync to one line command which synchronizes specified directories and not which are excluded?. Need help!
The exclude pattern is relative to the source files, not the destination files. You're actually excluding
192.168.2.100:/etc/etc/fstab
, which does not exist.You should use:
You should use something like this:
where the text file $backup_incl_from_file should include:
and the text file $backup_excl_from_file should include:
In this example
It's important you read the rsync man page before you use this example to meet your needs, paying special attention to the INCLUDE/EXCLUDE PATTERN RULES section.
The following is the rsync command to sync multiple directories in one-line and is worked for me. Please let me know if it is the right way to use.
This should be run on SOURCE system:
We can exclude many files/directories from specified directories.
If we have a file with the same name let say 'test' under /etc/ and /home and you want to exclude this file only from /etc, then placing a exclude entry excluding 'test' from all .
Try this in the Advanced Options window to exclude a directory and its sub directories
--exclude "/user/pathtodirectory*/" where 'user' is your user name and 'pathtodirectoy' is the the directory you want excluded, along with all its sub directories. Make sure you include the double quotes and forward slashes.
Example: --exclude "/johndoe/downloads*/"
Tested on both Ubuntu 14.04 and Ubuntu Gnome 14.04.