I am trying to use rsync to replicate all the files from one web server to another server that could act as a backup if the first one went down. The problem I am having is that the .htaccess file requires the AuthUserFile to have the fully quallified path to the .htpasswd file and I cannot make the paths the same on the two machines.

Does anyone know how I might use the same .htaccess file on two different servers?

Thanks for any help that can be provided.

link|improve this question

73% accept rate
feedback

3 Answers

up vote 3 down vote accepted

Yet another way to do it is to specify an exclude pattern, so that rsync won't touch the .htaccess file.

rsync --exclude-from=/home/user/.rsync/exclude.pat ...

And the exclude.pat file should be in this format:

- /.htaccess
- .htaccess

The first entry will tell rsync to exclude only the root .htaccess, the second one - to exclude all .htaccess files within the synchronisation tree. You can look it up in the rsync manual.

link|improve this answer
feedback

One option is to use a database for your authdb instead of a file via e.g. mod_auth_mysql. This completely mitigates the need to specify any sort of a filename.

link|improve this answer
That sounds like the correct way to do it. I was hoping for less involved solution but that definitely seems like the proper answer. – stephenmm Jun 7 '10 at 2:44
As an added bonus, you will also be able to edit the authdb over the web easily enough. – Ignacio Vazquez-Abrams Jun 7 '10 at 2:51
feedback

If you have shell access i think a simple sed/awk command after the rsync operation to change the path.

e.g.

sed s/tommy/joe/ < .htaccessSiteA > .htaccess

for more information, man sed or http://www.grymoire.com/Unix/Sed.html

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.