Here are the scripts I used before for syncing the DB daily (hourly,
whatever),
and for syncing my site data. Keep in mind, I have also setup
Passwordless ssh
too for this to work.. I also do all the copies over an internal IP address
(/etc/hosts = backupserver = 10.10.10.10 for example), I connected the two
servers with a crossover cable. The DB uncompressed is around 300+ MB, and
compressed is about 20MB.
#!/bin/sh
# get the date into a global variable
date=`date +%y%m%d%H%M`
# Dump the mysqldatabase, and bzip it to the backup directory.
mysqldump --compatible=mysql40 --add-drop-table -uUSERNAME -pPASSWORD DBNAME |
bzip2 -c > /var/backup/DBBACKUP-$date.sql.bz2
# I needed the --compatible=mysql40 flag/setting as am backing up from MySQL
4.1.15 and importing into MySQL 4.0.x
# Secure copy the database to the remote server
scp /var/backup/DBBACKUP-$date.sql.bz2
root@backupserver:/var/backup/DBBACKUP-$date.sql.bz2
# Run a command on the remote server to decompress the database from the bzip2
file.
ssh -t root@backupserver bzip2 -d /var/backup/DBBACKUP-$date.sql.bz2
# Import the decompressed file into mysql (takes a while!)
ssh -t root@backupserver "mysql -DDBNAME -uUSERNAME -pPASSWORD <
/var/backup/DBBACKUP-$date.sql"
#Clean up. Remove the remote decompressed file (=300+MB!)
ssh -t root@backupserver rm -f /var/backup/DBBACKUP-$date.sql
# NOTE THE LOCAL COPY OF THE COMPRESSED (BZIP2) DATABASE IS STILL LOCATED IN
# /var/backup... and must be cleaned out (eventually a script will be made to
remedy this).
Script Number 2 - Copy over site. (You could probably squish these scripts
together, but I run them at different cron times, since the site content is
updated every 3-6 hours, but the DB is updated constantly)
#!/bin/sh
#This script will sync the coldfusion files and pdf documents found in the
/var/www/html directory
#It will only transfer files that have been recently added or modified.
# Sink-it up now.
rsync -azupogtv --exclude /CFIDE -e ssh /var/www/
root@backupserver:"/var/www/"
# Ownership is now ROOT.ROOT, change ownership to webuser.webgroup
ssh -t root@backupserver chown -R webuser.webgroup /var/www/
enjoy.... :)
> Wow everyone... this is awesome information. The current site,
> although busy enough to move to a T1 is not likely to get /. ed We,
> based on the information you guys gave, are most likely to go with
> the main server, with a warm backup... most likely on site for speed.
> Tape can be stored off site for the big stuff.
>
> I have dealt with Microsoft SQL replication and I am not to
> comfortable with the whole replication load balancing thin. As I said
> I was moving out side my comfort zone here. I can see that the
> majority here would all agree to stay away if possible.
>
> Thanks Again
>
> Dick
>
> On 7/27/06, Dave Hall <dave-slg@dnh.sk.ca> wrote:
>> On Wed, Jul 26, 2006 at 11:36:40PM -0600, chris@fazekas.net wrote:
>> > Thanks for the comments Jeff. I should explain a touch more why I was
>> > looking
>> > to "overkill" my clients setup. He often gets hit by / . which is
>> good for
>> > business... when the server stays up and alive... :)
>>
>> How dynamic is the content? Is it really interactive and a pile of database
>> hits are justified for each request? Could some of the resulting pages be
>> cached? If so, rather than all the replication and stuff, perhaps putting a
>> caching server such as squid out front as a reverse proxy could provide an
>> easy win without another box to maintain.
>>
>>
>> --
>>
>> Dave
>>
>>
>> --
>> "Well, there's SPAM, egg, sausage, and SPAM. That's not got MUCH
>> SPAM in it."
>>
>> To unsubscribe, send a message with the word "unsubscribe" (without the
>> quotes) in the body to linux-request@slg.org
>> Archives are at http://list.slg.org/
>>
>
>
> --
> The significant problems we face cannot be solved by the same level of
> thinking that created them.
>
> --
> "Well, there's SPAM, egg, sausage, and SPAM. That's not got MUCH
> SPAM in it."
>
> To unsubscribe, send a message with the word "unsubscribe" (without the
> quotes) in the body to linux-request@slg.org
> Archives are at http://list.slg.org/
>
>
Received on Thu Jul 27 10:47:45 2006
This archive was generated by hypermail 2.1.8 : Fri Sep 08 2006 - 23:26:38 CST