Site Links
Home
Features
Documentation
Pricing & Order
Members Area
Support Options
UBBDev.com
UBBWiki.com
Who's Online
1 registered (Gizmo), 35 Guests and 15 Spiders online.
Key: Admin, Global Mod, Mod
Featured Member
Registered: 06/07/07
Posts: 4
Top Posters (30 Days)
Ruben 51
Gizmo 24
DennyP 24
Dunny 15
SteveS 14
AllenAyres 12
SD 10
dbremer 10
drkknght00 9
doug 8
Latest Photos
OK Corral Shoot Out
Testing
Basildon Train Station
Basildon Town Centre looking from the rounderbout
Basildon Town Square
Page 1 of 3 1 2 3 >
Topic Options
#184181 - 05/12/07 02:18 PM Cron + Backup Database
Mark S Offline
Carpal Tunnel
Registered: 07/04/06
Posts: 4447
Loc: Liverpool : England : UK
I do think this is somthing all Threads 7 users should know.
Cron + Backup Database.

Hi ive been rummaging around the tinternet,
and looking for a solution to backup mysql database
and also make it into a cron job for nightly back ups.

Why?
Well coming from classic we didnt have to worry about databases and looking after them, so if there was documentation covering this with Thread 6 then i dont have that documentation.

So now i'm on V7 Threads, and its all new, i'm now getting worried about backups and making sure i have steps in place
if somthing was to go wrong or DIE.

Currently i'm manually downloading them via my server control panel not phpadmin but via Direct Admin.(cp)
But there only about 30mb .tar.gz
But that is sure to grow and grow and then my problems will start.

So i'm asking for help with this as i have read on numerous occasions that once your database gets to xx size or time out
your asking for problems, and i would like to at the least
begin to address this before its too late.

 Originally Posted By: Gimzo
MySQL Export: mysqldump -uusername -ppassword dbname > dbname.sql
MySQL Import: mysql -h localhost -uusername -ppassword dbname < dbname.sql


I want be able to make a cron job (Script) to automate this in the night.
Links or any Help and advice would be appreciated. \:\)


Rather than tears later.

Thanks.
_________________________
Version v7.5.6 smile smile < Threads satisfaction status
People who inspire me Rick Gizmo Ian David jgeoff ntdoc
Oooo i hear 8 is coming? just after 7 my friend.
Top
Express Hosting
Express Hosting "We are the official hosting company of UBB.threads. Ask us about our free migration services to migrate your UBB.threads installation."
#184182 - 05/12/07 03:01 PM Re: Cron + Backup Database [Re: Mark S]
Philipp Offline
journeyman
Registered: 07/30/06
Posts: 82
I am using this script:

 Code:
#!/bin/sh
CDATE=`date '+%d'`

mysqldump -uusername -ppassword database > /home/backup/database.sql
tar czvf /home/backup/database.tar.gz /home/backup/database.sql
cp /home/backup/database.tar.gz /home/backup/databases/database-${CDATE}.tar.gz

This generates 1 month of database backups in the /home/backup directory. I am additionally using rsync to mirror the backup directory on my second server.
Top
#184183 - 05/12/07 03:29 PM Re: Cron + Backup Database [Re: Philipp]
Mark S Offline
Carpal Tunnel
Registered: 07/04/06
Posts: 4447
Loc: Liverpool : England : UK
Thank's \:\)
I'm going to play more than dumb, which isnt that dfficult
so it can help others who are curious.

The script about does need to be modified to suit your paths.
It needs to be saved in a file ending in .sh
uploaded to a directory to be used.

Is that about right?
_________________________
Version v7.5.6 smile smile < Threads satisfaction status
People who inspire me Rick Gizmo Ian David jgeoff ntdoc
Oooo i hear 8 is coming? just after 7 my friend.
Top
#184185 - 05/12/07 04:30 PM Re: Cron + Backup Database [Re: Mark S]
Philipp Offline
journeyman
Registered: 07/30/06
Posts: 82
 Quote:
The script about does need to be modified to suit your paths.

Yes

 Quote:
It needs to be saved in a file ending in .sh
uploaded to a directory to be used.

No, the .sh ending is not necessary. I called the script on my installation "zbackup".

You need to copy the script to your /etc/cron.daily directory and chmod it to 755. All scripts in this directory will be automatically executed every day in the morning.
Top
#184187 - 05/12/07 04:41 PM Re: Cron + Backup Database [Re: Philipp]
Mark S Offline
Carpal Tunnel
Registered: 07/04/06
Posts: 4447
Loc: Liverpool : England : UK
Thank you \:\)

I have the option via my cp (Direct Admin) to select the path
where the script would be located, and the cron can run from
there, well that's what I'm going to try.

What's your thoughts on this one?
I found it on a google search ?
Good or Bad ?

Its big but covers a lot of things too, e-mailing when done?
Or is it just over the top.

Link

Thanks for any help ;\)


Edited by Mark S (05/12/07 08:27 PM)
Edit Reason: Removed the copy and paste as it was Huuuuuge lol
_________________________
Version v7.5.6 smile smile < Threads satisfaction status
People who inspire me Rick Gizmo Ian David jgeoff ntdoc
Oooo i hear 8 is coming? just after 7 my friend.
Top
#184188 - 05/12/07 05:05 PM Re: Cron + Backup Database [Re: Mark S]
gliderdad Offline
Registered: 06/08/06
Posts: 1466
Loc: NY
I have a nightly cron job that backups the database and it is done through webmin.
Top
#184190 - 05/12/07 06:22 PM Re: Cron + Backup Database [Re: gliderdad]
Mark S Offline
Carpal Tunnel
Registered: 07/04/06
Posts: 4447
Loc: Liverpool : England : UK
Help i have a problem \:\(

Its either something stupid or something worse?

I'm in at root and i'm running the command just to test
the paths before a start any scripts.

I get this error and a google search shows 5 results \:\(

mysqldump: Got error: 1103: Incorrect table name 'test.sql' when doing LOCK TABLES

To get that error i'm typing in the following.
User name and passwords are changed.

mysqldump -uXXXX -p1234 my_table test.sql

Ive been trying to sort it for hours now \:\(

My Table name does have something similar too

my_table

but that's it?

i can connect in via the command line.
and if i run the mysqldump with out a file name
mysqldump -uXXXX -p1234 my_table
it wizzes past my screen in Putty and stops thankfully.

Any ideas Help !?
_________________________
Version v7.5.6 smile smile < Threads satisfaction status
People who inspire me Rick Gizmo Ian David jgeoff ntdoc
Oooo i hear 8 is coming? just after 7 my friend.
Top
#184192 - 05/12/07 06:46 PM Re: Cron + Backup Database [Re: Mark S]
Mark S Offline
Carpal Tunnel
Registered: 07/04/06
Posts: 4447
Loc: Liverpool : England : UK
Working now (O the fool)

mysqldump -uXXXX -p1234 my_table test.sql

is now

mysqldump -uXXXX -p1234 my_table >test.sql

Added ">"

May help someone, ?
_________________________
Version v7.5.6 smile smile < Threads satisfaction status
People who inspire me Rick Gizmo Ian David jgeoff ntdoc
Oooo i hear 8 is coming? just after 7 my friend.
Top
#184195 - 05/12/07 06:53 PM Re: Cron + Backup Database [Re: Mark S]
Gizmo Online   cat

Registered: 06/05/06
Posts: 14995
Loc: Portland, OR; USA
I use this (crafted her myself, modified as to not show all of my sites, since it can get extensive):

 Code:
[root@server code]# cat backup.c 
# Create Backups with Today's Date
tar -cvpzf /home/backups/code/temp/ugn-`date '+%d-%B-%Y'`.tgz /home/ugn/
tar -cvpzf /home/backups/code/temp/mysql-`date '+%d-%B-%Y'`.tgz /var/lib/mysql/
# Change permissions on the above files to local user.
chown -R backups:backups /home/backups/code/temp/
# Upload Data
/home/backups/code/temp
ncftpput -R -b -DD -P 2121 -f /home/backups/remotebackup.conf /data /home/backups/code/temp
# Email user with completion
echo "The monthly backup of critical domains has been completed" | mail -s "Monthly Backup Completed" owned.ugn


Basically:
Backs up webspace.
Backs up Database
Changes owner to the backup user.
Uploads to my home machine.
Deletes the backup on the server.
Emails me that its complete.

Now here my "backup MySQL" backs up the mysql data directory directly; you could easily just program in your MySQL dump paramaters in its place.
_________________________
Forums: UGN Security & VNC Web Design & Development
UBB.Threads: UBB.Wiki, My UBBSkins, UBB.Sitemaps
Longtime UBB Supporter, UBB Beta Tester & Resident Post-A-Holic.
UBB Modifications, Styling, Coding Services, Disaster Recovery, and more!
Top
#184197 - 05/12/07 07:00 PM Re: Cron + Backup Database [Re: Gizmo]
Mark S Offline
Carpal Tunnel
Registered: 07/04/06
Posts: 4447
Loc: Liverpool : England : UK
I'm finding all this very helpful, cheers
i'm sure its going to help others too.

I'm sure to post more lol...
Ive had to forget my script as ive been on with this and that
all day now and eyes are going fuzzy.
_________________________
Version v7.5.6 smile smile < Threads satisfaction status
People who inspire me Rick Gizmo Ian David jgeoff ntdoc
Oooo i hear 8 is coming? just after 7 my friend.
Top
Page 1 of 3 1 2 3 >



Moderator:  AllenAyres, Harold, Ian, Ron M 
Shout Box

Today's Birthdays
No Birthdays
Recent Topics
Temporary Password email not being received
by
05/24/12 10:02 PM
Ability to "like" individual posts (not Facebook "likes)
by doug
05/23/12 09:03 AM
Island Permissions
by ThreadsUser
05/22/12 03:03 PM
streaming video
by prkrgrp
05/20/12 07:02 PM
New Posts Corrupted? Can someone help?
by PianoWorld
05/19/12 09:41 AM
Forum Stats
10489 Members
36 Forums
33841 Topics
181707 Posts

Max Online: 978 @ 06/24/07 11:19 PM
Random Image