Active
Project:
backup
Version:
5.x-2.x-dev
Component:
Code
Priority:
Critical
Category:
Feature request
Assigned:
Reporter:
Created:
16 Mar 2007 at 10:33 UTC
Updated:
1 Mar 2008 at 14:09 UTC
Jump to comment: Most recent file
Please, don't mark it as dup of http://drupal.org/node/90677 because this other request is a compound one.
Here I only ask for one request: make backup work within cron drupal task. Backup should then be stored in the main directory and with a time stamp. It would be advisable, as per best practices, that the backup took into account the multi-site directory structure and that it included the contrib mods too.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | backup-patch-cron.zip | 20.29 KB | Petra |
Comments
Comment #1
dmuth commentedOn my TODO list!
Comment #2
filiptc commented+1
This is a critical feature
Comment #3
forseti commentedHere is a basic cron implementation, add this to backup.module
/**
* Implementation of hook_cron().
*
* removes backup files older than 24hrs.
*/
function backup_cron() {
watchdog('cron', "Cleaning old backup files...", WATCHDOG_WARNING);
$target = variable_get("backup_target", "");
$cleancmd = "find $target -name \"drupal-backup*tgz\" -type f -mtime 1 2>&1";
$cleanfp = popen($cleancmd, "r");
while ($line = fgets($cleanfp)) {
`rm -f $line`;
}
$retval = pclose($cleanfp);
}
I have almost finished a slightly better option for the cron that allows people to configure the time interval from 6, 12, 24 hrs or dissabled. Will post it too when properly tested.
Comment #4
Farreres commentedAn interesting addition to this would be the ability to specify the desired number of backups that should be kept. That way, I could ask for having one backup every 24 hours, and also to keep up to 3 of these backups. When a fourth is generated, the oldest would be removed.
Another thing that would be desirable is that, while backup is being executed, drupal should be set to maintainance mode automatically and they restored to working mode, all of this automatically.
Comment #5
dmuth commentedYes, I know this is a needed feature.
Right now, I am working on a feature to list/download/delete backups. When that is done, I will start on the cron feature.
Comment #6
dmuth commentedThat's actually what I'm working on right now before I get started on the cron functionality.
Sorry, but I am not propared to set the site automatically to maintenance mode while doing a backup. This would only spawn massive amounts of complaints from people who (justifiably) wanted to know why their sites were taken down while doing a backup. And, should the script exit abnormally and the site be left in maintenance mode... that would be bad.
-- Doug
Comment #7
Farreres commentedDoing a backup without the system being in maintainance mode would generate possibly inconsistent data. If you feel unfonfortable, it could be offered as a configurable option. Another interesting thing would be that this module changed the default maintainance message. When backup places the site in maintainance, the message would be "a backup is being made, please be patient. Security is a must". This way, in case the script fails abruptly, there is a hint as to why the site is blocked, and the system admin only has to log in and place it back in production mode. Just my ideas.
Comment #8
dmuth commentedFair enough -- I think an option would be workable. And I like your idea of changing the message that is displayed.
I will put that on my TODO list with the rest of the cron stuff.
-- Doug
Comment #9
dmuth commentedI just wanted to let folks here know that this will be happening soon. I finished off the system to view/delete existing backups, so I'll be able to concentrate on the cron system now.
I'll be out of town this coming weekend (April 1st), but I will return next week and begin work on cron functionality.
Thanks for being patient with me.
-- Doug
Comment #10
lonebrave commentedFirst off, let me say I love the simplicity of making backups with this module.
I've spent a couple days searching for ways to make automated backups with this module when I finally decided to check the requested features to see if integrating it with cron had been suggested yet. Much to my pleasure I found this request.
All the ideas posted above seem good. I, too, am in favor of configurable options versus forcing what may be controversial function on everyone.
I realize development on this is done in free time, and I'm patiently waiting. Is there any update on the progress, though?
Comment #11
dmuth commentedSomeone asked for a progress update, so here it is.
I have been amazingly busy the last 3-4 weekends, which meant no free time for me. :-(
There seems to be a lull in that though, so with a little luck I can take a whack at some of these bugs this coming week.
-- Doug
Comment #12
Petra commentedMake backup work within cron drupal task will be a good feature!
I don't know how large the most backups are - some people want to get their backups via email - my backup of a multisite-installtion is about 40MB...
Backup every 6 hrs sounds like a much visited side with Community (many postings/comments). Here should be thought also of people, which (must) use poormanscron.
To "all backups delete, which are older than 24h": imagine you are on vacation or you recover from a good party and someone hacks your side and you really need the backup. Then you have however only backups from your hacked side.
It should remain a backup from (e.g.) the 1. of month and from each first day of the week (and one from the last day). So one does not have to insure oneself each day that still everything is correct and if someone really messed up his site, he can restore it.
Advanced would be naturally a monthly fullbackup with weekly differential backups regarding the fullbackup and daily incremental backups regarding the weekly backups. But that is probably something oversized for this modules.
Comment #13
Petra commentedI tried it myself: I copied the lines from function backup_action_backup() into a new function backup_cron(), I added the line
include_once ("functions.inc.php");
and deleted all lines with drupal_set_message();. Likewise I inserted forsetis * removes backup files more older than 24hrs., however the files are to be deleted after 7 days (I want each day one backup and the oldest should be 1 week old).
For this I changed
$cleancmd = "find $target -name \"drupal-backup*tgz\" -type f -mtime 1 2>&1";to
$cleancmd = "find $target -name \"drupal-backup*tgz\" -type f -mtime mtime 7 2>&1";(don't know if it works, I had to wait a few days.)
In backup.module I can specify a directory where the backup will be written. If I specify a directory in drupal's root directory the backup works per cron. If I specify a directory in a subdirectory (for example: sites/example.com/backup) I receive after the first cronrun following error message:
backup_files(): Command 'tar cfz /tmp/backup-htdocs-zpjRL5 CHANGELOG.txt cron.php ... drupal-backup-db-20070714144432-955933870.sql.gz ' returned value: 2It is probably caused by the already existing backupfile. If I delete all old backupfiles, then cron runs completely and creates a backupfile .
@make backupfile smaller
I have my sites in one multisite-installtion and backup copies always the entire data base and all files. The backupfile momentarily has already 40 MB. How could one make it smaller?
- One idea is to empty the cache tables before, because these do not have to become backuped. But in a multisite-installtion cache_clear_all() would only empty the cache of the current domain, but not all cache tables of the other installations.
- Another idea is to make backup only for the current domain but therefor some changes would have to be made in the module.
Doug, are you working on cron functionality? Can I help, perhaps testing?
Comment #14
spyderpie commentedLove the backup module .. would love cron too :)
Comment #15
Petra commentedI wrote one - it keeps backupfiles for 8 days and makes a backupfile each cronrun.
Be carefull, backupfiles could have 100 MB and when you run cron 3 times a day, you would have 2400MB backupfiles...
This funktion needs to store the backup-files in a directory in the root-directory of drupal (you can define one on the administration-site).
backupfiles need to have chmod 0705 instead of 0604 for deleting the files when cron runs over crontab (it runs as anomymous)
change in functions.inc.php
put in backup.module
Comment #16
physiotek commentedi instaled the petra patch
i will look how it works and give feedback
Comment #17
Petra commentedI use it since I posted the patch - works fine.
If you have trouble using it, tell me, perhaps I can help.
Comment #18
Farreres commentedCould you please apply the patch and generate an alpha version people can test?
Comment #19
andrabr commentedI wish I was competent enough to add cronPlus support: it allows to differentiate when processes are run, and I am not paranoid enough for hourly backups ;-)
Comment #20
Petra commentedI can't apply a patch, cause I use an old version of backup.module.
But I attached the whole module - still works fine for me.
Comment #21
rapsli commentedPetra patch works fine.. also for newer versions. Including this into the module would be a nice feature!