I've written a backup script which does the following:
- retrieves a list of all tables in the database
- reads each table and writes the fields (tab-delimited) into a gzipped file (one for each table)
- encodes those files into email attachments and then deletes the files
- sends a single email with multiple attachments
Really the only issue is I think it's kind of ugly to get an email with 10 attachments (for the 10 tables) and it might be nicer to just get one attachment - a gzipped folder containing the 10 text files.
I see no problem creating a directory and writing each table as an uncompressed text file to that directory. I'm not sure how to gzip the whole directory though. The various gzipping functions appear to work on a string, so I'd have to read the folder and its contents into a single string, which I'm not sure how to do. Can it be done?
Or - is it even necessary? Maybe it's no big deal to get backup emails with 10 attachments.
Or I suppose one more alternative is to write all the data from the tables to a single file, with some kind of divider between the tables. I can probably scope the way phpmyadmin creates dump files and just copy the way it does it.
Advice & comments?
Thanks,
Bob