Rsync unexpectedly removing ALL files

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Rsync unexpectedly removing ALL files

Koehn, Troy N.

I am using rsync with --files-from option with a file named 'rsync.in' that contains 37K+ directories that are queried from a database. One of the directories looked like this:

 

/home/usr/directory/./

 

I know the directory should NOT end with a './' but this was stored in the database that way by another process. When performing the rsync, this one directory caused all files from the root '/' directory on down to be deleted. However, if ran without the --files-from option it works as expected. It is because of the ‘./’ on the end and using the ‘files-from’ option but I don’t know why rsync would do that.

 

Obviously not allowing these directories to be stored in the database in the first place is the thing to do, but I just want to understand why rsync would do this so I can ensure I prevent things like this in the future. Here's the command (with the dry-run option for safety).

 

rsync --dry-run --perms --delete --compress --dirs --links --times --keep-dirlinks --files-from=/usr/home/rsync.in /home/src/shared/directory/ /

 

BTW, rsync  version 3.1.0  protocol version 31


--
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
Reply | Threaded
Open this post in threaded view
|

rsync unexpectedly removing ALL files

Koehn, Troy N.

I am using rsync with --files-from option with a file named 'rsync.in' that contains 37K+ directories that are queried from a database. One of the directories in the database actually looked like this:

 

/home/usr/directory/./

 

Probably some sort of typo when the directory was entered. When performing the rsync command below, this one directory caused all files on the destination server to be deleted from the root '/' directory on down. Obviously I have put in safeguards now to filter invalidly formatted directories, but I want to understand why rsync would do this in case there are other things I should be looking for. BTW, it only seems to happen if using the –files-from option. If ran manually from the command line it does not delete all files. I have searched the web and can find no one else who has experienced this.

 

Note: If you test this, please use the –dry-run option

 

rsync --dry-run --perms --delete --compress --dirs --links --times --keep-dirlinks --files-from=rsync.in source_machine:/home/src/shared/directory/ /

 

 

Thanks for any assistance.


--
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
Reply | Threaded
Open this post in threaded view
|

Re: rsync unexpectedly removing ALL files

Wayne Davison-2
On Mon, Jun 6, 2016 at 8:52 AM, Koehn, Troy N. <[hidden email]> wrote:

One of the directories in the database actually looked like this:

 

/home/usr/directory/./


In the manpage under the "--relative" option (which is implied by --files-from) there is this information:

It is also possible to limit the amount of path information that is sent as implied directories for each path you specify. With a modern rsync on the sending side (beginning with 2.6.7), you can insert a dot and a slash into the source path, like this:

rsync -avR /foo/./bar/baz.c remote:/tmp/

That would create /tmp/bar/baz.c on the remote machine. (Note that the dot must be followed by a slash, so "/foo/." would not be abbreviated.)
 
Thus, your path tells rsync to take the contents of the /home/usr/directory path and send its contents without any implied directories, which puts its content at the root of the transfer.

..wayne..


--
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html