automatically backing up via email?
Moderator: General Moderators
- titaniumdoughnut
- Forum Commoner
- Posts: 33
- Joined: Wed Jul 13, 2005 2:02 pm
- Location: Manhattan
automatically backing up via email?
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.
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.
-
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
-
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
-
Something simple as the following script could already be sufficient (untested)
You can also place a tar or bz2 in between 
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;- titaniumdoughnut
- Forum Commoner
- Posts: 33
- Joined: Wed Jul 13, 2005 2:02 pm
- Location: Manhattan
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.
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.
- titaniumdoughnut
- Forum Commoner
- Posts: 33
- Joined: Wed Jul 13, 2005 2:02 pm
- Location: Manhattan
- titaniumdoughnut
- Forum Commoner
- Posts: 33
- Joined: Wed Jul 13, 2005 2:02 pm
- Location: Manhattan
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.
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
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)- titaniumdoughnut
- Forum Commoner
- Posts: 33
- Joined: Wed Jul 13, 2005 2:02 pm
- Location: Manhattan
- titaniumdoughnut
- Forum Commoner
- Posts: 33
- Joined: Wed Jul 13, 2005 2:02 pm
- Location: Manhattan