Discussion:
[rdiff-backup-users] [bug] Excluding hidden files the wrong way doesn't result in an error
Ilario
2017-01-04 19:00:14 UTC
Permalink
Excluding a hidden file without full path doesn't rise an error (as
happens with non hidden files) and copies it anyway; e.g.

mkdir temp
cd temp
mkdir .one
mkdir .two
mkdir three
mkdir four
rdiff-backup --exclude .one --exclude ./.two --exclude ./three . ../backup
ls -a ../backup
. .. four .one rdiff-backup-data

copies also the .one file and gives no warning.
Does the dot have a special meaning there?
Thanks,
Ilario

_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-***@nongnu.org
https://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki
Adrian Klaver
2017-01-04 19:11:49 UTC
Permalink
Post by Ilario
Excluding a hidden file without full path doesn't rise an error (as
happens with non hidden files) and copies it anyway; e.g.
mkdir temp
cd temp
mkdir .one
mkdir .two
mkdir three
mkdir four
rdiff-backup --exclude .one --exclude ./.two --exclude ./three . ../backup
ls -a ../backup
. .. four .one rdiff-backup-data
copies also the .one file and gives no warning.
I am not seeing a .one file I see a .one/ directory so I would say you
need to do:

--exclude .one**
Post by Ilario
Does the dot have a special meaning there?
Thanks,
Ilario
_______________________________________________
https://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki
--
Adrian Klaver
***@aklaver.com

_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-***@nongnu.org
https://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki
Ilario
2017-01-04 22:40:00 UTC
Permalink
Post by Adrian Klaver
Post by Ilario
Excluding a hidden file without full path doesn't rise an error (as
happens with non hidden files) and copies it anyway; e.g.
mkdir temp
cd temp
mkdir .one
mkdir .two
mkdir three
mkdir four
rdiff-backup --exclude .one --exclude ./.two --exclude ./three . ../backup
ls -a ../backup
. .. four .one rdiff-backup-data
copies also the .one file and gives no warning.
I am not seeing a .one file I see a .one/ directory
Yes, sorry, I meant directory, anyway I can see the same behaviour with files.
Post by Adrian Klaver
so I would say you need
--exclude .one**
Does this work for you? It doesn't for me...

_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-***@nongnu.org
https://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki
Dominic Raferd
2017-01-05 11:41:51 UTC
Permalink
Post by Ilario
Post by Adrian Klaver
Post by Ilario
Excluding a hidden file without full path doesn't rise an error (as
happens with non hidden files) and copies it anyway; e.g.
mkdir temp
cd temp
mkdir .one
mkdir .two
mkdir three
mkdir four
rdiff-backup --exclude .one --exclude ./.two --exclude ./three . ../backup
ls -a ../backup
. .. four .one rdiff-backup-data
copies also the .one file and gives no warning.
I am not seeing a .one file I see a .one/ directory
Yes, sorry, I meant directory, anyway I can see the same behaviour with files.
Post by Adrian Klaver
so I would say you need
--exclude .one**
Does this work for you? It doesn't for me...
It does seem slightly strange behaviour by rdiff-backup. I think it is
better not to rely on backing up from the current directory but
instead to specify the directory explicitly as the source. Then
specify it explicitly for all excludes - or use ** instead
(remembering that this will also exclude similarly named
files/directories further down the tree). e.g.

mkdir -p ~/temp/.one
mkdir ~/temp/.two
mkdir ~/temp/three
mkdir ~/temp/four
rdiff-backup --exclude ~/temp/.two --exclude **/three ~/temp ~/backup
find ~/backup -mindepth 1 -path "*rdiff-backup-data" -prune -or -print

You should see:
/home/[name]/backup/.one
/home/[name]/backup/four

_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-***@nongnu.org
https://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki
Adrian Klaver
2017-01-05 14:44:39 UTC
Permalink
Post by Ilario
Post by Adrian Klaver
Post by Ilario
Excluding a hidden file without full path doesn't rise an error (as
happens with non hidden files) and copies it anyway; e.g.
mkdir temp
cd temp
mkdir .one
mkdir .two
mkdir three
mkdir four
rdiff-backup --exclude .one --exclude ./.two --exclude ./three . ../backup
ls -a ../backup
. .. four .one rdiff-backup-data
copies also the .one file and gives no warning.
I am not seeing a .one file I see a .one/ directory
Yes, sorry, I meant directory, anyway I can see the same behaviour with files.
Post by Adrian Klaver
so I would say you need
--exclude .one**
Does this work for you? It doesn't for me...
I was going from memory and did not actually try the pattern.
My memory was faulty:(

Turns out I had the ** in the wrong place:

***@tito:~/temp> rdiff-backup --exclude **one --exclude ./.two --exclude ./three . ../backup

***@tito:~/temp> ls -a ../backup/
. .. four rdiff-backup-data
--
Adrian Klaver
***@aklaver.com

_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-***@nongnu.org
https://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki
Robert Nichols
2017-01-05 15:25:52 UTC
Permalink
Post by Ilario
Excluding a hidden file without full path doesn't rise an error (as
happens with non hidden files) and copies it anyway; e.g.
mkdir temp
cd temp
mkdir .one
mkdir .two
mkdir three
mkdir four
rdiff-backup --exclude .one --exclude ./.two --exclude ./three . ../backup
ls -a ../backup
. .. four .one rdiff-backup-data
copies also the .one file and gives no warning.
Does the dot have a special meaning there?
Since the directory you are backing up is ".", all your excludes have
to begin with either "./" or "**". The only thing that is strange
here is that you are not getting the "cannot match any files in the
base directory" error. For some reason, dotfiles in an exclude do
not trigger that message.
--
Bob Nichols "NOSPAM" is really part of my email address.
Do NOT delete it.


_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-***@nongnu.org
https://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki
Ilario
2017-01-05 16:40:34 UTC
Permalink
Post by Robert Nichols
Post by Ilario
Excluding a hidden file without full path doesn't rise an error (as
happens with non hidden files) and copies it anyway
The only thing that is strange
here is that you are not getting the "cannot match any files in the
base directory" error. For some reason, dotfiles in an exclude do
not trigger that message.
This is exactly my point :)

I think I spotted something related looking into the code:

https://github.com/sol1/rdiff-backup/blob/4864f2fcc195a1a0b3d303766505b58f16223bff/rdiff-backup/rdiff_backup/selection.py#L402

That line should rise an error if the exclusion doesn't include the
origin path. But it just compares text strings, without a directory
separator (e.g. the slash).

So in some cases (like mine) the error doesn't rise, e.g.:
rdiff-backup --exclude data origin backup # it fails, as expected
rdiff-backup --exclude origin/data origin backup # it does not fail,
as expected (doesn't matter if origin/data esists)
rdiff-backup --exclude origindata origin backup # it does not fail,
but it should!

Fixing the linked line of code should be easy (appending a "/"
literally or using os.path.join() prior to string comparison).

_______________________________________________
rdiff-backup-users mailing list at rdiff-backup-***@nongnu.org
https://lists.nongnu.org/mailman/listinfo/rdiff-backup-users
Wiki URL: http://rdiff-backup.solutionsfirst.com.au/index.php/RdiffBackupWiki
Loading...