Automatically sending backup to an email address using the API

amirw

New member
Joined
Dec 20, 2005
Messages
3
Hi all,

I'm trying to make an automatic backup of my database to an email. If it doesn't succeed I will go for the FTP option but I prefer using gmail for this since it's always online.

My idea is:
1. Run a Cron Job daily
2. Cron Job runs a PHP file
3. PHP file uses DirectAdmin API
4. Get http://domain.com:2222/CMD_DB/db-file.gz
5. Send to GMail.

If there's a limit on the mail server, maybe it's possible to split the file to several messages.

I know there's an API for full backup:
PHP:
#create a backup
action=backup

I don't want to use it because the first option creates a backup, lets you save the file and the deletes it. The backup API keeps the file on the server and I don't want that to happen, unless you know of a way to delete this file after usage (it's CHMOD'd 640)

I'd be happy to hear your ideas about this. My other option is to use the same method but to FTP this file instead.

The built-in scheduled backup only allows to make a full backup of all the files. This is too big for me and I need only the database.

Thanks for your replies,
Amir W.
 
Last edited:
If it's only a MySQL database that your after, you could avoid DirectAdmin altogether, and make the backup directly in your php script so you would have full control over it.
 
I'm not sure I follow.
To be clearer - my server is running in Safe Mode so making a full backup can lead to a timeout using PHP. I want to use DirectAdmin backup because it can't time out.

This is especially important because after the backup I intend to split the backup file and send it in small packages to override the mail maximum limit.

I've got 20mb message limit, a Safe Mode with 30 seconds timeout, so it's limiting my options.

If 30 seconds will not be enough, I'm going to use two cron jobs - one for backup and split files, and the second for emailing and erasing the temp files.

My real question is how do I get this file using API:
http://domain.com:2222/CMD_DB/db-file.gz
 
Last edited:
Back
Top