Page 1 of 1
automatically backing up via email?
Posted: Thu Jul 28, 2005 1:41 pm
by titaniumdoughnut
I hope this isn't a dumb question, but I've done a bit of searching and can't find anything.
The tools I have available are a Linux server, c-panel and phpMyAdmin.
I'm trying to figure out a way to schedule automatic backups of the mySQL databases. The only safe place I can think of to put the backed-up files is my gmail account, seeing as all my websites are on the same server.
Is there a way to do this? Could a cron job with some kind of PHP script do it? I know nothing about this type of thing.
Posted: Thu Jul 28, 2005 2:04 pm
by djot
-
Hi,
If you have a way to use cron jobs, you may start your backups automatically.
If not, you may (mis-)use a well visited website to call you backup script. With each visit you may check whether it's time to do a backup.
backup scripts: there are some scripts special made for backing up databases. You only need PHP and your database for this.
Some of these scripts directly allow sending backups per email, ftp them to other servers or just store them on the current server. (Customizing them to send email should not be too difficult).
djot
-
Posted: Thu Jul 28, 2005 2:07 pm
by timvw
Something simple as the following script could already be sufficient (untested)
Code: Select all
#!/bin/bash
# notice the lack of a space between -p and password
mysqldump -u username -ppassword -h hostname databasename | mail user@example.com -s "e;this is the backup of `date +%Y-%m-%d`"e;
You can also place a tar or bz2 in between

Posted: Thu Jul 28, 2005 2:18 pm
by titaniumdoughnut
Thanks
djot, very clever. There aren't any visitor-up-dateable bits of data, so I could test to see if it's time to backup whenever an admin logs in.
Tim, that looks amazingly simple... the only trouble is, I don't know what it is
What type of script is it? Where do I put it and how do I call it?
Thanks guys.
Posted: Thu Jul 28, 2005 2:28 pm
by djot
-
? if you don't have access to cronjobs, nor may use shell scripts (what is above from timvw) you will have to use a way like I described, where one website calls backup scripts on another website. And yes, this is very clever :)
djot
-
Posted: Sat Jul 30, 2005 8:47 am
by titaniumdoughnut
I'm going to try running that as a cron job today, and see what happens. thanks!
ps - if my site goes down, send for help

Posted: Sat Jul 30, 2005 9:01 am
by titaniumdoughnut
hmm... I filled it out to the best of my ability (un and pw are for the database user, right?) and put it into the cron tab, set to execute every minute, for testing. Then, after I submitted it, it just disappeared, and the cron tab is still empty. I'm afraid to poke around further, because I haven't a clue what I'm doing.
Posted: Sat Jul 30, 2005 9:21 am
by timvw
How have you installed it in the crontab?? I've fot a feeling you are using something like CPanel etc...
If you have shell access you can use "crontab -e" to edit your crontab file..
Or "crontab -l" to list the file..
It could look like
Code: Select all
1 3 * * * /usr/bin/mysqldump -u timvw -ppassword databasename | /usr/bin/mail timvw@gmail.com -s "e;MySQL backup of `date +%Y-%m-%d`"e;
# * * * * * *
# | | | | | |
# | | | | | +--------- command to be executed
# | | | | +---------------- day of week (1 - 7) (monday = 1)
# | | | +------------------- month (1 - 12)
# | | +---------------------- day of month (1 - 31)
# | +------------------------- hour (0 - 23)
# +--------------------------------------- min (0 - 59)
Posted: Sun Jul 31, 2005 10:42 am
by titaniumdoughnut
Yes, I did use C-panel... is that bad?
I'll poke around a bit and try to figure out if I have shell access. How would I log in? Do you have to use a special program? Could I use the OS X Terminal?
Posted: Sun Jul 31, 2005 10:46 am
by timvw
I have absolutely no experience with CPanel and friends, so i can't say if they are good/bad/whatever..
I login with a SSH2 client.. I don't know OSX terminal, so can't help you there..
But it all comes down to editting your crontab file.. and isntalling it.. no matter how you do it.
Posted: Mon Aug 01, 2005 11:37 am
by titaniumdoughnut
thanks
I'll get this working eventually! You've been very helpful.