Is it possible to rsync your web site to another backup server and use the same .htaccess files?

1

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.

stephenmm

Posted 2010-06-07T02:32:46.797

Reputation: 1 197

Answers

4

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.

Igor Zinov'yev

Posted 2010-06-07T02:32:46.797

Reputation: 313

3

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.

Ignacio Vazquez-Abrams

Posted 2010-06-07T02:32:46.797

Reputation: 100 516

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 – 2010-06-07T02:44:39.283

As an added bonus, you will also be able to edit the authdb over the web easily enough. – Ignacio Vazquez-Abrams – 2010-06-07T02:51:30.770

2

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

bubu

Posted 2010-06-07T02:32:46.797

Reputation: 9 283

-1

Yes it's possible

Login to your server via SSH. Navigate to the directory you'd like to transfer files to with the commands

Allen Smiths

Posted 2010-06-07T02:32:46.797

Reputation: 1