Problem with files-from option in rsync

I am trying to transmit a set of specific files via rsync. The man page says the the option to do this is --files-from=filename however when I run this:
Code:
rsync  -a --relative  --files-from="/root/postfix.rsync"    /tmp

I get the error:
Code:
[root@mx31 ~]# rsync error: syntax or usage error (code 1) at options.c(2352) [client=3.1.3]

The file /root/postfix.rsync contains:
Code:
[root@mx31 ~]# cat /root/postfix.rsync
/usr/local/etc/postfix/access
/usr/local/etc/postfix/canonical
/usr/local/etc/postfix/generic
/usr/local/etc/postfix/header_checks
/usr/local/etc/postfix/relay_clientcerts
/usr/local/etc/postfix/relay_domains
/usr/local/etc/postfix/relocated
/usr/local/etc/postfix/sender_access
/usr/local/etc/postfix/sender_mx_access
/usr/local/etc/postfix/sender_ns_access
/usr/local/etc/postfix/transport
/usr/local/etc/postfix/virtual
/usr/local/etc/postfix/virtual.regexp
/usr/local/etc/postfix/smtpd_sasl.conf
/usr/local/etc/postfix/rbl_reply
/usr/local/etc/postfix/postscreen_access.cidr
/usr/local/etc/postfix/postgrey_whitelist_recipients
/usr/local/etc/postfix/postgrey_whitelist_clients.local
/usr/local/etc/postfix/postgrey_whitelist_clients
/usr/local/etc/postfix/helo_checks.pcre
/usr/local/etc/postfix/helo_access.pcre
/usr/local/etc/postfix/header_checks.regexp

The rsync command works as expected if I remove the --files-from option and simply place each individual file name in the command line:
Code:
[root@mx31 ~]# ll /tmp/usr/local/etc/postfix/access
ls: /tmp/usr/local/etc/postfix/access: No such file or directory
[root@mx31 ~]# rsync  --relative "/usr/local/etc/postfix/access"   /tmp
[root@mx31 ~]# ll /usr/local/etc/postfix/access
-rw-r--r--  1 root  wheel  22059 Jun 15  2018 /usr/local/etc/postfix/access

The test rsync command is about as simple as it can possibly be. What is my error?
 
Have a look at https://stackoverflow.com/questions/16647476/how-to-rsync-only-a-specific-list-of-files

I don’t know where they got this info from as the man page appears to suck, but it looks like you still have to provide a source and dest, and the list of files is relative to the specified source.

The working invocation is:
Code:
rsync  -a --relative --files-from="/root/postfix.rsync"      /      /tmp

Note that the file names in the files-from file are found relative to the provided source. For example:

#/root/postfix.rsync contains /usr/local/etc/postfix/access
# command is: rsync -a --relative --files-from="/root/postfix.rsync" / /tmp
# result is: /tmp/usr/local/etc/postfix/access

# /root/postfix.rsync contains /etc/postfix/access
# command is: rsync -a --relative --files-from="/root/postfix.rsync" /usr/local/ /tmp
# result is: /tmp/etc/postfix/access

# /root/postfix.rsync contains /etc/postfix/access
# command is: rsync -a --relative --files-from="/root/postfix.rsync" /usr/local/ /tmp/usr/local/
# result is: rsync: mkdir "/tmp/usr/local" failed: No such file or directory (2)

# mkdir -p /tmp/usr/local/
# /root/postfix.rsync contains /etc/postfix/access
# command is: rsync -a --relative --files-from="/root/postfix.rsync" /usr/local/ /tmp/usr/local/
# result is: tmp/usr/local/etc/postfix/access

1. The source and destination must both be provided to rsync.
2. The file names in the files-from= file are relative to the source provided to rsync.
3. The destination file names are relative to the destination.
4. The --relative option will create missing directories descending from the destination, but the destination directory must exist.
 
Back
Top