LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 08-16-2005, 09:21 PM   #1
critical
Member
 
Registered: Feb 2005
Location: New Zealand
Distribution: Debian, Ubuntu
Posts: 46

Rep: Reputation: 15
Question Auto backup of www and mysql


Hey there team

I'm working on a project with me and a friend...

I currently run apache & mysql

I would like to setup a cron to automatically backup the database and several directories on the server?

Can anyone show me an example of the cron script I need?

Thanks
 
Old 08-16-2005, 09:38 PM   #2
Half_Elf
Guru
 
Registered: Sep 2001
Location: Montreal, Canada
Distribution: Slackware; Debian; Gentoo...
Posts: 2,163

Rep: Reputation: 45
it depends how you want to backup

the easiest way would be something like : (using cp there)

15 4 * * 6 root cp -a /where/your/www/folder/is /mnt/where/to/backup
 
Old 08-16-2005, 09:43 PM   #3
critical
Member
 
Registered: Feb 2005
Location: New Zealand
Distribution: Debian, Ubuntu
Posts: 46

Original Poster
Rep: Reputation: 15
15 4 * * 6 root cp -a /where/your/www/folder/is /mnt/where/to/backup

What exactly will that do?

every 15 minutes? it will copy the website into that directory?...

what does the 4 * * 6 mean?

also do I just run crontab -e ? and add that there?..


also do you have any idea how to backup the mysql database?

 
Old 08-16-2005, 10:21 PM   #4
critical
Member
 
Registered: Feb 2005
Location: New Zealand
Distribution: Debian, Ubuntu
Posts: 46

Original Poster
Rep: Reputation: 15
I've got this so far

30 0 * * * DATE=$(date +%Y%m%d%M%H) && mkdir /var/backup/drumandbass/public_html/$DATE/ && cp -a /home/drumandbass/public_html /var/backup/drumandbass/public_html/$DATE/

Look okay?
 
Old 08-16-2005, 10:24 PM   #5
critical
Member
 
Registered: Feb 2005
Location: New Zealand
Distribution: Debian, Ubuntu
Posts: 46

Original Poster
Rep: Reputation: 15
woohoo I just became a member
 
Old 08-16-2005, 10:54 PM   #6
Half_Elf
Guru
 
Registered: Sep 2001
Location: Montreal, Canada
Distribution: Slackware; Debian; Gentoo...
Posts: 2,163

Rep: Reputation: 45
Quote:
15 4 * * 6 root cp -a /where/your/www/folder/is /mnt/where/to/backup

What exactly will that do?
Every satursday at 6h15 am, it will copy "/where/your/www/folder/is" to "/mnt/where/to/backup" the "-a" option is to make sure it will keep the same owership/right.

It could be a good idea to use "tar" instead however, as it will take less space. You could replace the cp part with something like :
"tar -cpsjf /mnt/backup/www.tar.bz2 /where/to/www" (this tar and bunzip, so it will be compressed).

To backup the MYSQL database, just do the same about the MYSQL directory (something like /usr/lib/var/mysql I believe?).

Quote:
30 0 * * * DATE=$(date +%Y%m%d%M%H) && mkdir /var/backup/drumandbass/public_html/$DATE/ && cp -a /home/drumandbass/public_html /var/backup/drumandbass/public_html/$DATE/

Look okay?
Yup, it will backup every day at 12h30 am. The "date" part is a real good idea. But you should consider using "tar" instead of "cp -a" if you are concerned about your disk space. Otherwise keep it that way, it's easier to find back something in a directory than in a tar archive.
 
Old 08-18-2005, 02:13 AM   #7
critical
Member
 
Registered: Feb 2005
Location: New Zealand
Distribution: Debian, Ubuntu
Posts: 46

Original Poster
Rep: Reputation: 15
This wasn't working for me for ages...

This is what i ended up doing...

made a simple backup script using SH

made cron call the script and let the script do the work

Poblem solved
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
auto backup digity Linux - Software 2 09-07-2005 08:13 PM
How do I setup an auto backup to an email address? glenn69 Linux - General 5 10-10-2004 06:26 AM
Mysql backup? marghorp Linux - Software 11 02-24-2004 01:18 PM
how do I turn off auto http://www in galeon & konqueror?? thegreatgatsby Linux - Software 1 09-28-2003 11:21 AM
mysql backup ram_dhupkar Linux - General 13 09-09-2003 07:19 PM


All times are GMT -5. The time now is 09:19 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration