News:

Wondering if this will always be free?  See why free is better.

Main Menu

Auto MySQL Backup

Started by Owen, August 19, 2004, 05:55:32 AM

Previous topic - Next topic

IchBin™

You could create another script to compress the attachments directory in a similar fashion.
I haven't tested this, nor am I a great script writer, just my thoughts anyway. :)

#! /bin/sh
DATESTAMP=`date +%m-%d-%Y-%H%M`
cd /home/username/backup
rm *.gz
gzip >$DATESTAMP.attachment.gz /home/username/path/to/attachments/
IchBin™        TinyPortal

WizardHawk

I would think that adding the last line of your script right after the mysqldump line of the other script would do both in one easy script. I'll play around with it and see how it works. Thanks for the help. Been too long since I've played with linux.

WizardHawk

I attempted to add that script ichbin and got this from the cron reply>
gzip: /home/removed/public_html/removed/attachments/ is a directory -- ignored

It created a 0 length file

Also, I noticed that the sql backup is a raw dump file. In case I ever need to actually restore from this backup, what do I do with it? Can the cPanel backup program restore this kind, do I need to do it in myPhPadmin (and where)?

I sure don't want to be in a panic looking around for info when the day comes I need such a backup restored. Thanks for the help guys!

WizardHawk

No one can help with a script that can backup the entire content of the attachment folder? The one mentioned is missing someting to tell GZ to zip all files in that folder and it errors out.

Having a script that not only backed up the sql database daily but also included the entire attachment folder (and possibly avatar folder for those who keep them seperate now) would make a nice, neat bundle for restoring any problems.

Random

Quote from: Tony on November 12, 2003, 07:18:06 PM


You then need to use Control Panel to setup a cron job with these paremeters.... Feel free to change them, but they work out to be 2am everyday ;) when its less busy.

Minute: 0
Hour: 2
Day: *
Month: *
Weekday: *

So it looks like this...........

0 2 * * * {username} /home/username/daily.sh


Oh, you obviously have to change the username/dbnames in the scripts and also take out the curly brackets ;)

And CHMOD the bash script to chmod +x daily.sh

Good luck

Tony,


I was following this ok till this point, can someone explain to me really slowly where I do this and how?  ;D  I can't work it out  :(

WizardHawk

Quote from: Random on October 29, 2005, 06:30:03 PM
Quote from: Tony on November 12, 2003, 07:18:06 PM


You then need to use Control Panel to setup a cron job with these paremeters.... Feel free to change them, but they work out to be 2am everyday ;) when its less busy.

Minute: 0
Hour: 2
Day: *
Month: *
Weekday: *

So it looks like this...........

0 2 * * * {username} /home/username/daily.sh


Oh, you obviously have to change the username/dbnames in the scripts and also take out the curly brackets ;)

And CHMOD the bash script to chmod +x daily.sh [nofollow]

Good luck

Tony,


I was following this ok till this point, can someone explain to me really slowly where I do this and how?  ;D  I can't work it out  :(
You have to either have cpanel as your domain managing software, or another one that enables you to have access to cron jobs in order to run these scripts. Open your cpanel and if you don't see the icon "Cron Jobs" then contact your web host to see if they allow you to use that feature. If you do have that icon, open it and select 'standard' as the view you want. Now put your email address in that you want outputs to go to (you will only get emails if the cron job fails for some reason or has error messages). In the 'command to run' section, put /home/username/daily.sh (Replace username with your actual account user name). Change the time that the job should be ran to what it says above. Click 'save crontab' at the bottom to save this job.

If you followed everything else and put those scripts on your server in the correct location and gave proper access to them (CHMOD), then you should get a response from one of the scripts saying it did the backup and you will find a new file in your backup folder.

Random

Ahh, that explains why I couldn't work it out, think I have ensimn (or something like that) not cpanel.  Guess I'll have to just keep backing up manually.  Thanks for the help  :)

viulian

For anyone interested in automated backup of the the forum database - please check out this thread: http://www.simplemachines.org/community/index.php?topic=115957

Advertisement: