Trailing slash in destination

Gavin Schokman gavins at cse.unsw.EDU.AU
Thu Apr 24 15:20:28 EST 2003


Good afternoon all,

I'm currently working on a backup script that will fetch a set of logs
from remote machines and store them on a central machine.

The command I'm using is of the form

${RSYNC} -avz root@${site}:/data/access_* ${LOG_REPOSITORY}/${site}/

Each site usually holds about 8 files with the prefix "access_". Some
machines however only have one, and this is where my problem arises.
When the script attempts to collect the logs from one of these machines, I
get the following error:

open /home/test/squidlogs//site1/.JQRG86 : No such file or directory

The problem is caused by the way rsync ignores trailing slashes in the
destination.
In the above, instead of creating the site1 directory and saving the
access_0.gz file in it as site1/access_0.gz, rsync tries to write
(temporarily) to site1/.JQRG86.
Since there is no site1 directory yet, this is not a valid Linux file
name.

The actual code that is responsible for this is the get_local_name()
function in main.c

static char *get_local_name(struct file_list *flist,char *name)
{
  struct stat st;

	.
	.
	.

  if (flist->count == 1)
    return name;

	.
	.
	.

}


i.e. if there is only one file to be copied, take the destination
argument, including the trailing slash, as the destination file name.

My question (we had to get to it at some point :)

Is there a reason for rsync ignoring trailing slashes ?
To me, the trailing slash semantics for the source are natural. This would
also be natural for the destination argument.
Having to write special cases in my script to handle this seems like a
complete waste, when it could be handled more efficiently directly by
rsync.

I was going to write a patch for this, but I'm interested in whether this
is intentional.


Kind regards,
Gavin Schokman


-------------------------------------------
Gavin Schokman
B.E. Computer Engineering (Honours), CCNA
University of New South Wales, Australia

mailto: gavins at cse.unsw.edu.au
website: http://www.cse.unsw.edu.au/~gavins




More information about the rsync mailing list