User Tools

Site Tools


merkalt:database_backup

This is an old revision of the document!


Merkalt.no DB backup

There is a necessity to make regular backup of DB tables for Merkalt site instances.

Usually DB backup is performed as cron job. On merkalt host cron job is not supported. So we could resolve this problem with a help of so-called “pseudo-cron” script. The idea consists in launching of pseudo-cron script from usual site page. I think, it could be sendmail.php. Visiting of this page by site users will start pseudo-cron script.

First of all, backup script should work periodically but not every time when users visit this page. For this purpose additional DB table should be used. This table will contain following information:

  • launching script name - the full path to backup script to be launched as pseudo-cron job;
  • backup period - time (in days or hours) between sequential backups;
  • last backup date - the date and time of last successful backup.

On the basis of this data pseudo-cron script should make decision if next DB backup should already be made or not. If current date and time is greater then last backup date plus backup period then backup script should be launched. Otherwise - shouldn't.

NOTE: Pseudo-cron script SHOULD NOT USE any external libraries (like mysql.inc.php, etc.) and should be realized only with a help of native PHP functions.

Backup files should be gzipped, stored ouside of sites accessible area. If size of gzipped backup file will not too big then backup should be sent via e-mail as attached file. But file size issue should be explored first. Third party script whcuch probably will be used for DB backups could be found in merkalt.com/test/_db_backup folder. Backup file will exclude ONLY tables of test instances (tables with 'tst_' prefixes). DB backup will not be provided for Labelyourbelongings.com instance for a while.

Question

Size of each created backup (compressed by gzip) currently is about 3Mb. It seems such files too large to be sent as e-mail attachment. May be it makes a sense to include in e-mail the link for this file downloading but not the file itself?

merkalt/database_backup.1284622144.txt.gz · Last modified: (external edit)