Page 1 of 1

How to mirror files in different folders without duplication

Posted: 2014-04-01 11:10
by !
Currently, we have two different domains (foolsdesign.org+techtalk.cc) which use the same MSSQL database but different phpBB code files. This is because we want to share members and uploaded files between these two domains.

phpBB uses a local "files" folder to store all the uploaded files and images. This folder cannot be a virtual IIS folder. So how did we solve the problem of having the exact same files, in two different "files" folders without mirroring and duplicating the files? The answer is to use NTFS symbolic links (junction points). We used Windows Sysinternals, "Junction v1.06" - By Mark Russinovich to create this junction point.

With that tool, it's very simple:

(Please note that "<***>" is just a censured folder name to not publish our exact server file locations on the Internet.)

Code: Select all

C:>junction.exe "c:<***>   echtalk.cc<***>files" "c:<***>foolsdesign.org<***>files"

Results in:

Code: Select all

Created: c:<***>   echtalk.cc<***>files
Targetted at: c:<***>foolsdesign.org<***>files

Which means that "c:<***> echtalk.cc<***>files" doesn't exists but looks like it does exist and it points to the real location of the files which is at "c:<***>foolsdesign.org<***>files".

Note that when you want to create a junction point, you must not already have a folder with the same name there. In our case, you cannot have an existing "c:<***> echtalk.cc<***>files", "files" folder. The "junction.exe" program will create that "files" folder for you. If you already have an existing "files" folder, it will give an error:

Code: Select all

Error creating c:<***>   echtalk.cc<***>files:
Cannot create a file when that file already exists.

Your junction point will look like this in Explorer:

junction point.PNG
junction point.PNG (18.41 KiB) Viewed 9561 times

If you delete the junction point, the original files will not be deleted. I tested this on some test folders. Don't take my word for it, however! Test this yourself on some non critical folder!

Another way to delete the junction point is to use this command:

Code: Select all

C:>junction.exe -d "c:<***>   echtalk.cc<***>files"

Sadly, I am unable to cache the "junction.exe" file in here (you will have to download it from Microsoft's Web site) because of "Eula.txt" which says:

...
You may not:

* work around any technical limitations in the binary versions of the software;
* reverse engineer, decompile or disassemble the binary versions of the software, except and only to the extent that
applicable law expressly permits, despite this limitation;
* make more copies of the software than specified in this agreement or allowed by applicable law, despite this limitation;
* publish the software for others to copy;
* rent, lease or lend the software;
* transfer the software or this agreement to any third party; or
* use the software for commercial software hosting services.
...

Therefore, fuck you Microsoft! :evil:

2414.jpg
2414.jpg (60.1 KiB) Viewed 9561 times