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