Members: 16,996
Threads: 38,846
Posts: 159,391
Online: 22

Newest Member: Kl_broka@rediffmail.com


Odoo.tv - Outdoor Television


Sedo - Domains kaufen und verkaufen das Projekt mambers.com steht zum Verkauf Besucherstatistiken von mambers.com etracker® Web-Controlling statt Logfile-Analyse

Go Back   Mambers.com > Mambo 4.5.1 > Mambo 4.5.1 General Talk

Reply
 
LinkBack Thread Tools Display Modes
Old 11.12.2004, 01:42   #1 (permalink)
TVB
Mamber
 
Join Date: Oct 2004
Posts: 62
TVB is on a distinguished road
Default Cronjobbing your mambo (or any mysql db for that matter)--a short tutorial

This is a script that was put together by another Futurequest site owner that I have changed very slightly for my own purposes

If you comfortable backing up via command line, then hopefully this will help you. I suspect if you are backing up this way, you already know this stuff.

If you don't know how to backup via command line or a cron job, it's real easy to follow the instructions (I hope they are---I tried to make them easy).

Please note this is for a *nix setup and your setup or file structure on your server may be different. I am unable to offer support for it as I only know it works for me, and hopefully it will for you as well. Use at your own risk and enjoyment.

I'm posting it because I am always seeing a lot of questions on backing up.

*********************
Step 1. Using your file manager or your ftp client, create a directory called dbbackups above the www level (for example: /big/dom/xyourdomain/dbbackups) Chomod it to 700.

.
Step 2. using notepad or your favorite text editor create a text file with the following contents:

Code:
#!/bin/bash
/usr/local/mysql/bin/mysqldump -uxyourdomain -pyourpassword -q -hmysql.yourdomain.tld xyourdomain >/big/dom/xyourdomain/dbbackups/mambobackup.txt
after the -u is your username for mysql
after the -p is your password for mysql
after the -hmysql is yourdomain.com or .net or whatever tld your domain has

Following that is the name of the database you are using to run mambo. If you need help remembering which database you used to run mambo, check your config.php file in your mambo or check with phpMyadmin.
After the /big/dom/x insert your actual domain name (no tld this time)

Name this text file mambobackup.sh and install it at the root ( /big/dom/xyourdomain/mambobackup.sh ) & Chomod it 700.

Step 3. Telnet into your account with your favorite SSH client (I like Putty) using your ftp username and password. On the command line enter /big/dom/xyourdomain/mambobackup.sh and hit enter. Put your actual domain in place of yourdomain in the example.

Step 4. From your file manager or your ftp client, check the contents of the folder at /big/dom/xyourdomain/dbbackups/ and inside it you should find a file named mambobackup.txt which is a copy of your mysql database used to run your mambo.

I also use vbulletin and have the same exact script installed substituting "forum" for "mambo" wherever it occurs. Both backup to the dbbackups directory


Automating your backup:

Important-if you have a crontab job already running, these instructions will overwrite it. Chances are, if you have one running, and want to make backups automated, you will want to add this to your existing crontab job and then reinstall it.

Step 1. Using your favorite text editor create a text file with the following contents.

MAILTO=you@yourdomain.tld
5 10 * * * /big/dom/xyourdomain/backupscript.sh


make sure that after .sh you hit enter at least once to create a line feed. Put your actual domain name and tld in place of yourdomain.tld and put your actual domain in place of xyourdomain. Name this file cronjob.txt and install it above the www, ( /big/dom/xyourdomain/cronjob.txt )Chomod it 700

Using your favorite telnet client, telnet into your account using your ftp username and password. On the command line enter

crontab /big/dom/xyourdomain/cronjob.txt

and hit enter. At 10:05 am server time, each day, a new file will overwrite your old one and you will have a daily, fresh backup made automatically for you at /big/dom/xyourdomain/forumbackup/backup.txt You can of course adjust the timing of the backup, by changing the first two entries of cronjob.txt In the example, the 5 is minutes and the 10 is hours. If you wanted the backup to be done at 11:00 PM each day, you would put 0 23 as the first two numbers. However, as it is shown will work fine.

One consideration in making backups is server storage space or disk usage.

Automating your backup and saving disk space by gzipping your backup file

With 1 more file, and a change in the cronjob.txt file, it's easy to create an automated backup file in in a zipped format (which cuts the space used by about 25%. This is what you will need to add:

1. Create a text file called zip.sh

Inside this file, put in the following code, replacing xyourdomain with your actual information.

Code:
gzip -9 -f /big/dom/xyourdomain/dbbackups/mambobackup.txt
(I have a second line of code here doing the same for our vbulletin forums, substitituting forumbackup.txt for mambobackup.txt)

Install this file above the www ( /big/dom/xyourdomain/zip.sh ) and chomod it 700. This script will make mambobackup.txt into mambobackup.txt.gz

2. You will now need to modify the cronjob.txt file as follows replacing yourdomain.tld and xyourdomain with your actual information.

MAILTO=you@yourdomain.tld
5 10 * * * /big/dom/xyourdomain/backupscript.sh
10 10 * * * /big/dom/xyourdomain/zip.sh

after the last .sh be sure to hit enter at least once to insert a line feed. Install the new file in place of the old one above the www ( /big/dom/xyourdomain/cronjob.txt)

Telnet into your account from CNC using your ftp username and password and on the command line put

crontab /big/dom/xyourdomain/cronjob.txt

and hit enter. Replace yourdomain with your actual domain information.
What will happen is that at 10:05 AM each day, a file called backup.txt will be created in the forumbackup folder. At 10:10 AM each day, that file will be zipped up and made into backup.txt.gz and then gzip automatically deletes backup.txt. This series of events will happen automatically each day until you cancel the crontab job.

You may change the timing of this by changing the first two numbers on the 2nd and 3rd lines in the cronjob.txt file to suit yourself. IE to run this at 1:05 PM and finish it at 1:10 PM the crontab.txt file would be

MAILTO=you@yourdomain.tld
5 13 * * * /big/dom/xyourdomain/backupscript.sh
10 13 * * * /big/dom/xyourdomain/zip.sh

Depending upon your site's busy times, it is best to schedule a backup during slower times of useage. When the backup is being made by the mambobackup.sh script, the site or forum is locked and on a larger site, this could last for 20-30 seconds while myslq dumps the data. You won't lose any data or posts, but your site may appear to be sluggish during this time.

Betsy
TVB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 20.01.2005, 14:12   #2 (permalink)
Baby Mamber
 
Join Date: Nov 2004
Posts: 2
brianilland is on a distinguished road
Default Re: Cronjobbing your mambo (or any mysql db for that matter)--a short tutorial

This is just what I need. Though what I also want to do is backup my entire site using a cronjob. Can this be combined with this? If so, any chance of some instructions as intuitive as your original post
brianilland is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 20.01.2005, 22:23   #3 (permalink)
TVB
Mamber
 
Join Date: Oct 2004
Posts: 62
TVB is on a distinguished road
Default Re: Cronjobbing your mambo (or any mysql db for that matter)--a short tutorial

I don't have time to write out a full tutorial right now but you can do this from the command line and get a back up on the fly:

$cd /big/dom/xyourdomainname/www
$tar --exclude=stats/* -czpf filename.tar.gz *
Navigate to your cgi-bin directory and type
$tar -czpf filename-cgi.tar.gz *

The first two lines are for the www directory. The second set is to back up your cgi-bin files if you have access to it and use it. It's been a while since I've used this as I do practically all development locally and then ftp the stuff in, keeping a local copy.

If I have time this weekend, I can try to put together a tutorial for the above.

As always, your usage, requirements and file structure may differ.

Betsy

One note about the original db backups...it overwrites your back-up daily. I only keep one backup at anytime and it's always the most recent so it works for me.
TVB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mambo Open Source 5.0 Book Series mmx Community Announcements 13 19.09.2005 09:35
Mambo OS 4.5 Installation tutorial *Animated* pixelsoul Mambo 4.5 Installation and Upgrades 8 05.09.2004 09:14
Hide/Show modules tutorial for Mambo template ahkane Template Discussions 3 07.06.2004 22:32


All times are GMT +2. The time now is 09:37.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
A vBSkinworks Design
© Copyright 2004-2008 by Arthur Konze Webdesign.