• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Mirroring 2 web servers

LuckyTaxi

Diamond Member
Trying to mirror two web servers. I can rsync but then I thought about it some more.

Here are the issues.

- 6 sites on production server. each folder is own by different user
- dont want to generate public keys for root (i think if i rsync as root the permissions will transfer over correctly)
- i used one account (testuser) and rsynced the directories over, but unfortunately the folders on the backup server inherits "testuser" as the owner of the files.

So what do I need to do to transfer the permissions over correctly w/o using the root user?
This way I dont have to create a cronjob for 6 users.

Command I used:

rsync -avz <source> <destination>
 
-a will only preserve file ownership if you run the command as root.

Are you just looking to have a backup server in case the primary fails?
 
yes and -a works just fine as root. The files came over with the correct username and permissions.
If i use a user other than root, it applies that user's credentials to the files.

In the event server1 fails, we switch to server2 by modifying dns.
 
What about using SSHFS to mount your web root(s) on server1 to server2 then running the rsync as root on server2? You would need to create a user that would have read access to the web directories and create a public key for it.

root@server2:~$ useradd -G fuse,<anyothergroups> user2 (so user has permissions to run sshfs and whatever you need to do so it has read permissions of web files on server1)
root@server2:~$ lsmod | grep fuse (make sure fuse module is loaded, if not, modprobe it)
root@server2:~$ sshfs user2@server1:/var/www /backup/www
root@server2:~$ rsync -avz --delete /backup/www/ /var/www/ (use --delete to get rid of files on the destination that no longer exist on the source)
root@server2:~$ fusermount -u /backup/www (unmount when done)
 
i ended up using the root using. We lock SSH access from office and between servers in the DC. I would hope that's secure enough if someone did hack into the system from the outside.
 
If you are running this as a script, you could rsync the files as a user, and then run some chown commands to fix the ownership changes.

Another option would be drbd.
 
Originally posted by: Brazen
If you are running this as a script, you could rsync the files as a user, and then run some chown commands to fix the ownership changes.

Another option would be drbd.

ah ... i didnt think of that one. thanks!
 
Back
Top