LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Auto backup of www and mysql (https://www.linuxquestions.org/questions/linux-software-2/auto-backup-of-www-and-mysql-354038/)

critical 08-16-2005 09:21 PM

Auto backup of www and mysql
 
Hey there team :D

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 :D

Half_Elf 08-16-2005 09:38 PM

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

critical 08-16-2005 09:43 PM

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?

:scratch:

critical 08-16-2005 10:21 PM

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?

critical 08-16-2005 10:24 PM

woohoo I just became a member :D

Half_Elf 08-16-2005 10:54 PM

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.

critical 08-18-2005 02:13 AM

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 ;)


All times are GMT -5. The time now is 03:43 PM.