Copy Link
Add to Bookmark
Report
NULL mag Issue 05 24 Mystic BBS backup from shinobi
+^^^---^^^---^^^---^^^---^^^---^^^---^^^---^^^--
-^^^---^^^---^^^-+ | M ystic BBS B a
6Cckup - two machines setup | +...---...---...
---...---...---...---...---...---...---...---...-+
Hello All, this article is about a way of backing up the M
ystic BBS over the net in the two machines setup. The possibl
e reason is one machine having fast Internet connection and s
mall disk space and the second more and cheaper disk space.
This article assume You have Mystic BBS installed on Your system. It
can receives connection, files and messages from users. It sends and
receive files from FTN networks. Now it grew a bit and You'
6Cre in the front of the decision on how to effectively backup
Your system. There are several approaches. I assume Yo
ur BBS runs on Linux. You have two computers on disposal. The
first computer is the BBS node (let's call it source node) i
9Cn the place where it receives traffic from outer Internet. Th
3Cat could be DMZ or rather server provider's farm. The other c
omputer we will call the archive machine (or target node).
Now what You want to do is to backup Your BBS on regular basis. And
You want to have the environment where You could do the system changes
without affecting the production BBS. There should be possibility to
recover lost or corrupted message bases or recover from other failure.
The one method I came up while thinking about it is as follows:
1) You will make a copy of Your system from the source ma
chine 2) You will compress and backup the copy on t
Che target machine 3) You will maintain the compress
ed copies on target machine All this is chosen bec
2Cause this strategy brings the opportunity to both have full b
ackup on target for Your disposal. That means in case You wou
ld detect any problem on the source You can switch to the targ
et machine a bring up the BBS without any struggle. The backup
copy on target can be easily recovered to the source machine using the
opposite direction of the sync process. Let's implement it in
2Cfollowing steps described below: 1) incrementally tran
sfer the BBS from source to target (backup) machine:
rsync -razv --delete <source>:/app/bbs /app The rsy
nc is available on most Linux distributions by default. It pro
vides functionality to synchronize source and target folders. The
source and target folders can be on different machines. You can do th
Cat locally of course in case You have enough space. But I assume
Your disk-space is more expensive on the live BBS than on the archive
machine. The options used says: -r - recursi
ve follow all folders to synchronize between source and t
arget -a - archive - this will assure You'll synchr
Conize file attributes -z - compress the files duri
8Cng the transfer to save some traffic -v - verbose
- this option allows the progress of synchronization to b
e written on standard output and thus let us debug the pro
cess. Later on this option can be removed [49D --delete
- this will allow us to synchronize file deletions and thus
keep the BBS target copy in sync with the source <s
Cource> is the name for the machine. What rsync uses is the ~/.
ssh/hosts file. In this file You can provide alias for Your source
machine. Example of such configuration can be as follows:
Host source C Hostname bbs.example.com
C User sysop This will provide us the opportu
nity to connect to host bbs.example.com under user sysop when
command: ssh source is issue
d. There is one more trouble to be solved and that's the authe
ntication process during the connect to remote system. That means
You have to generate ssh keys on the target machine and put it into t
he ~/.ssh/authorized_keys on the source machine. I would let this up
to You but generally You want to generate dsa private key using ssh-k
eygen then extract the public part of the key from the private
key and put that string into the ~/.ssh/authorized_keys on the source
machine. Hint: [ ssh-keygen -t dsa ssh-keygen
-y -f ~/.ssh/id_dsa > ~/.ssh/id_dsa.pub ... somet
imes it is necessary to put correct permissions on ~/.ssh fold
er and files under it. Usually You want to do something like chmod
-R 600 ~/.ssh. That will specify the read and write privileges only
for the owning user of the files in the folder and files and folders
under it. [9D Once this is done You can easily test You did everyth
ing right by issuing: ssh source
and getting the prompt without the need to enter password or specify
username. [9D Once this is done and You have access to the source m
achine from target machine You're almost done. Now it's time
to decide when You'll backup Your BBS. The sane possibility w
ould be something like 4 A.M. 2) Now once You have the
4C copy of Your BBS at the target machine (and You can try if i
t transferred correctly by running the BBS on target)... it's
time to archive it into the folder where the backups will be
stored. This is the next line: [38D tar -zcvf /app/a
rc/bbs_`date +%Y%m%d`.tgz /app/bbs tar is the comp
ression program that makes archives easily opened on any syst
em. The used options are this: [38D -z - gzips (com
presses) the files to save some space -c - create
new archive 3D -v - be verbose (this can be removed a
ftewards everything works fine) -f - this will all
ow us to specify the filename [47D the next word is the
0C path to the destination where the backups will be placed. A
nd it will create files in the following format e.g.: bbs_201
90220.tgz What we are using here is the ` bracket. When someth
ing is escaped in these on Linux it will cause bash to call su
Cbprocess, run the command in it and return the result back as
string. So when we issue: `date +%Y%m%d` it will
2C print the year, month and day and put it into the filename
The third argument is simple the source of the archive to be made of
(in this case /app/bbs 3) So now we have the rsynced copy on t
arget. We compressed our very first copy of it. And what we n
eed is to somehow handle the growth of the files in the time.
2C What we will use here is the deletion or given files older t
han e.g. 7 days (or just any time You'll specify). This will
allow us to have some full copies of BBS to go in case of failure
of the original. This will be used as follows: find /ap
p/arc -type f -mtime +7 -name '*.tgz' -execdir rm -- '{}' \;
find is the program in Linux that will give us the list of files we
are seeking folder in the specified folder (1st argument). So it will
seek in /app/arc. Now we don't want to mess up with the directories.
That's the option -type f and we want to consider only files older th
Can 7 days with the tgz extension. This is done by the options:
-mtime +7 -name '*.tgz' 3D Lastly we want to remove the
9Ccopies it returns (tgzs older than 7 days) and that's the res
4Ct. 4) Now we want to store these three lines into the
shell script file that we'll place into the root of the /app
folder (for example). So let's put this into the /app/bbs_bac
kup.sh file: #!/bin/bash rsync -razv -
-delete source:/app/bbs /app tar -zcvf /app/arc/bb
s_`date +%Y%m%d`.tgz /app/bbs find /app/arc -type
0Cf -mtime +7 -name '*.tgz' -execdir rm -- '{}' \; T
he first line is there only to make the system happy and provide
information on what are we dealing here with. D We'll give the /
app/backup_bbs.sh correct privileges so it could be run:
chmod u+x /app/backup_bbs.sh 8D This will allow
the owner of the file to run it. Now we can run it. And see
what will happen. 5) Once You're happy with Your backup
solution You can put it into the cron using:
crontab -e and inserting something like this:
04 00 * * * /app/backup_bbs.sh > /dev/null # BACKUP B
BS And that's it. This will synchronize Your BBS o
n the target machine with the source and provide compression
and history of Your belowed BBS. BTW: The above
described procedure assumes You want full backup of BBS. If Y
ou want Your backups smaller. You would move Your files from F
ile Bases to another directory and create symlink. Then just b
ackup the program files and eventually the Message bases.
Happy BBSing & take care Shinobi DISCLAIME
R: I take no responsibility from the damage or harm caused by
following the principles and instructions described in this article.
|08Shinobi <.Phenom.>