Tuesday, August 11, 2009

Excluding specific folder from directory crawlers

Shortly: I want to have a directory D:\bekap\mybackup that cannot be traversed.
I made a backup program that backs up data from a specified directory to another directory. (The program has much more features such as detecting duplicate data and to have efficient incremental backup.) I wanted to backup the whole D: drive, but that is the only partition available for the backup destination. Therefore I can only backup D: to let's say D:\bekap\mybackup.
The problem is, when the program traverses or walks through D: to find available files, in the end it will also go to D:\bekap\mybackup and it would try to back up files inside D:\bekap\mybackup to itself. (It's a similar problem with tar -cf archive.tar .).
So I want to make D:\bekap\mybackup not detectable except by directly accessing it through the path name. It is similar as if you have a non-linked web page at http://example.com/private_photos/xyz/; only people you give the address will be able to access it.
After trying through several options, I found a way to do that:
  • Go to the Security properties of D:\bekap (in Explorer: right click, properties, you may need to disable the Use simple file sharing in Folder Options)
  • Click Advanced button, then you will see entries similar to these:
  • Click Add, fill in your username, then click Check Names, then OK.
  • Tick the Deny column for the entry List Folder / Read Data.
Now you cannot access D:\bekap, but if you type D:\bekap\mybackup, you can open the contents!
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\>cd bekap

D:\bekap>dir
Volume in drive D is Dadu
Volume Serial Number is 1293-1777

Directory of D:\bekap

File Not Found

D:\bekap>cd mybackup

D:\bekap\mybackup>dir
Volume in drive D is Dadu
Volume Serial Number is 1293-1777

Directory of D:\bekap\mybackup

2009-08-11  15:22    <DIR>          .
2009-08-11  15:22    <DIR>          ..
2009-08-11  15:22                 0 .bekapkeren2
2009-08-11  15:22        35,616,973 .cache.ser
2009-08-07  17:43    <DIR>          data
2009-08-11  15:21    <DIR>          fs
          2 File(s)     35,616,973 bytes
          4 Dir(s)  82,628,956,160 bytes free

No comments:

Post a Comment