I'm using rsync as part of a system to create nightly snapshots of several servers, much like several people are appearently doing. However, I have a bit of a problem with things that I don't want backed up. On most of the systems, things like devfs, procfs, sysfs, etc don't need backed up. In addition, I have directories from one server NFS mounted on several of the other servers - specifically /home, among others. My backup scheme is currently that the backup server initiates the connection, and pulls the current state. As I'm already doing this over ssh, one possible solution is to have my script ssh in to the remote machine, parse the output of `mount`, and generate an include or exclude list from that. However, from reading the way the inc/exclude lists work, if someone happens to have made a directory named dev, for example, then it'll be excluded from the backups, since the list appears to be reapplied at each deeper stage in the directory traversal. Potentially, I could change the backup structure so that I back up each individual filesystem into a separate directory, and use "rsync -x" for each mountpoint. That gives me an ugly backup tree, though. My whole point is that I want a complete copy of each server that can easily be restored to an arbitrary machine. So, what I'm looking for is possibly a way to make excludes relative to the root at the beginning of the operation - so that if I specify "rsync --exclude /dev host:/ /backup/host", only /dev on host is excluded, not /home/user/dev, etc. Alternatively, it'd be great if I could specify a command line argument that listed just the fstypes to include (or exclude). Alternatively, is it possible to set up an rsync server on each of the machines to be backed up, with the server excluding portions of the directory tree? This is all on an internal network, so I can reasonably trust IP-based access controls to provide adequate security - though I really would prefer to stick with server-pull rather than client-push for the backups. Thanks. --Danny
On Wed, Jan 19, 2005 at 10:44:42AM -0600, Danny Sauer wrote:> So, what I'm looking for is possibly a way to make excludes relative > to the root at the beginning of the operation - so that if I specify > "rsync --exclude /dev host:/ /backup/host", only /dev on host is > excluded, not /home/user/dev, etc.That is precicely what already happens. The only way it would exclude a "dev" further down in the transfer is for you to have specified "dev" instead of "/dev" -- the leading slash anchors the exclude at the base of the transfer. There is a script that can generate an exclude list for you based on mount points. One version is attached to bug #1455, but I just checked in a slightly improved version into the "support" dir of the CVS source. You can see it here: http://rsync.samba.org/ftp/unpacked/rsync/support/mnt-excl It may not be quite what you want, but it would be easy to adapt its directory-trimming algorithm to work with some other list of exclusions other than the one taken from /proc/mounts. Doing that would let you create a file of exclusions with absolute paths and have the script select and trim only the excludes that were relevant for a transfer from the indicated source directory.> Alternatively, is it possible to set up an rsync server on each of the > machines to be backed up, with the server excluding portions of the > directory tree?Sure, that's easy. See the "exclude" and "exclude from" directives in the rsyncd.conf file. These excludes are relative to the "path" specified for the module, so they affect every transfer no matter what subdir the user specifies for the source. They make the files vanish as far as the client is concerned, though, which affects --delete. ..wayne..
Reasonably Related Threads
- What's wrong with my exclude rules?
- Asterisk 11 and old Thomson 2030S Hardphone => SIP Register/Auth Problem against V11
- Excluding a . directory in a subdirectory
- Asterisk 11 and old Thomson 2030S Hardphone => SIP Register/Auth Problem against V11
- better to exclude at daemon/server or client