How to replicate a Linux web site content to a remote site

S. Dimitri file mirroring software

In this post, I will describe a configuration to replicate a Linux web site to another remote site. We will replicate everything required to restart the site on a remote server. The same replication can be used with UNIX or Windows.

We can replicate between different hardware and different operating systems.

Although we are discussing a web server replication, the same article applies to any other server (physical or virtual) replication.

Introduction

In this example web server www.example.com will be replicated to www2.example.com.

Replication configurations are located under $edpcloud/etc.

We will replicate everything needed to run the server on the remote site, including the database

What will we replicate

We will replicate only the following directories.

/var
/home
/etc
/usr

We will create $edpcloud/etc/includes to instruct the replication software to only replicate what is in the includes file.
The includes file uses regular expressions.

bash-5.1# cat includes
^/home/.*
^/var/.*
^/etc/.*
^/usr/.*

What we will not replicate

We will use $edpcloud/etc/excludes to exclude certain file or directory patterns using regular expressions.

www# cat excludes 
^/var/www/edxthemesite2/htdocs/myusage/.*
^/usr/local/licenses/.*

File replication configuration

We will create $edpcloud/etc/eddist.cfg which controls replication. Here  replication set l1 has a sender and a receiver section.

Sender www.example.com will replicate data to www2.example.com.

Receiver www2.example.com will store replicated data in “/backup6t/sync3/%month%/%weekday%”.

 

<?xml version="1.0" encoding="UTF-8"?> 

 <config name="ExapleCo" password="ThisISMyKnownPwdd122467$?" workers="2">
<link name="l1"  >
<sender hostname="www.example.com"
/>
<receiver hostname="www2.example.com"
storepath="/backup6t/sync3/%month%/%weekday%" archivedir="/backup6t/syncarchive3/%date%" archive="1"
archiveexcfile="archiveexcludes"
/>
</link>
</config>

 

Receiver www2.example.com will store replicated data in “/backup6t/sync3/%month%/%weekday%”.

Here the “%variable%” will be resolved at run time as follows:

  • %month%:  Month of the year (01 to 12)
  • %weekday%: Week Day (Monday to Sunday)

Notice that we also configured the archive directory to be archivedir=”/backup6t/syncarchive3/%date%” where:

%date%  is in the format of  YYYYMMDD. What this means is that any file that changed will be archived in the archive directory so we will have previous versions if we find the file under /backup6t.

Running replication

Replication can be run from a scheduler, command line or in real time.

Running replication from command line

To replicate /home:

edq -l l1 -r www2.example.com -n /home

 

Running replication in a schedule:

You can either use cron or edscheduler.cfg to replicate data:

Example:

 

www# cat edscheduler.cfg
0 7 * * * /usr/local/enduradata/edpcloud/bin/edq - l l1 -n /home
0 7 * * * /usr/local/enduradata/edpcloud/bin/edq - l l1 -n /var/www

Running replication in real-time

To replicate a directory in real-time, we create $edpcloud/etc/edfsmonitor.cfg

www# cat edfsmonitor.cfg

/home

/var/www

To restart replication services

#www edpcloud.sh startall

To stop data replication services

#www  edpcloud.sh stopall

 

To dump and replicate the mysql database used by our web server

DBDUMP=/tmp/wwwdbname.sql
/usr/local/bin/mysqldump --user=root --password='SOmePassWord" wwwdbname > $DBDUMP 
/usr/bin/gzip $DBDUMP
edq -l l1 -n ${DBDUMP}.gz



How to replicate a Linux web site content to a remote site was last modified: May 1st, 2025 by S. Dimitri

Share this Post