Jump to content

Cronjob Database Backup


kixe

Recommended Posts

  • 2 weeks later...

@BernhardB & Marty
You can install the module via Soma's Modules Manager or download it manually and put it in the modules folder. This should work. I will try to fix installation with the 'Download and Install' option in PW.

1 hour later:

I could fix it. Should work now. Thank you for reporting.

Edited by kixe
  • Like 2
Link to comment
Share on other sites

  • 1 month later...

@kixe

Thank you for this module - I don't know how I managed to overlook it until now. It should come in very useful.

Is there any chance you could either add an option to allow the automatically generated filename to include the creation date, or move the filename generation into a hookable method so people can supply their own name generator if needed?

Regardless of the above request, thank you again!

  • Like 3
Link to comment
Share on other sites

  • 2 weeks later...

Moderator note:

@Linda789

I am treating your post as spam unless you can prove otherwise.

You joined the forums today, and submitted 2 posts with a link to an outside resource which suspiciously looks like unauthorised advertising on your part.

Edited by kongondo
Possible spam
Link to comment
Share on other sites

K so I've now been using this module for 6 days and everything is working perfectly, lovin' it. So I guess the only thing that I would like is to be able to limit the amount of backups that this module creates and have that setting somewhere accessible either through a hard coded variable or the admin interface. I'm thinking just a delete function that is called when the latest backup is complete.  I'm going to take a look and see if that is something that I may be able to contribute.

Link to comment
Share on other sites

  • 3 months later...

Version update 1.1.0
Extended Module Setting Options
 

  • Max number of backups
    Minimum 1, default and maximum 100 (defined in constant MAXFILES). Executed with each cron.
     
  • Deadline
    Will remove backups older than selected time interval with each cron.
     
  • Name format syntax
    # placeholder for db-name. Use surrounding % to escape date() format.
     
  • Remove backups from module settings dialog
    Select how many backups you want to keep in storage. Klick *SAVE* to execute.
  • Like 3
Link to comment
Share on other sites

I am working on this, but hadn't time to do. As a starting point this could help

date_default_timezone_set('GMT');

$path = "/home/yoursite/backups"; // full server path to the directory where you want the backup files (no trailing slash)

$hrs = 3600;
$days = 24 * $hrs;

$todaysdate = date('Ymd', time());

// Live Site Cutoff
$livecutoff = date('Ymd', (time() - (7*$days)));

$target = $path . "/site/" . $todaysdate . ".tar.gz";

$filelist = scandir($path . "/site");
foreach ($filelist as $backupfile) {
	if (stristr($backupfile, ".tar.gz")) {
		$filedate = explode('.tar.gz', $backupfile);
		if ($filedate[0] < $livecutoff) {
			unlink($path . "/site/" . $backupfile);
		}
	}
}

system("tar --create --preserve --gzip  --file=".$target." ~/public_html ~/mail ~/ftpconf",$result);
$size = filesize($target);
switch ($size) {
  case ($size>=1048576): $size = round($size/1048576) . " MB"; break;
  case ($size>=1024);    $size = round($size/1024) . " KB"; break;
  default:               $size = $size . " bytes"; break;
}

This is just a snippet for a first approach, nothing to use as is.

  • Like 1
Link to comment
Share on other sites

are you planning to add this kind of functionality to your module some day? any planned date for this?

i'm just curious. no real need for me right now because i'm using plesks backup feature. i was just wondering because the database is just one part of the whole...

Link to comment
Share on other sites

nothing planned. I think this feature could be useful in case of providing file uploads for frontenduser or so. Until now I have no need for this feature. Maybe tomorrow ... :rolleyes:

Link to comment
Share on other sites

as I said no need for me now. All assets I have to deal with are stored on my or my customers local machine. But you are right in case of file upload option for visitors file backup is a must.

Link to comment
Share on other sites

but how do you handle situations like when somebody deletes some files, then you restore a DB backup and the files referenced in the file-field are not stored in the filesystem any more?

good question. For all file backups I rely on a combination of my daily\weekly\monthly backups through whm, I don't allow users to empty the trash and use the trashman module to allow users to restore any accidentally trashed files instead. I find that really clamping down on user permissions cuts down on these worries.
Link to comment
Share on other sites

  • 5 months later...

I have upgraded PW to the latest dev version (21) and now I get the following error if I want to open a backup:

Error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in /home/.sites/24/site1275/web/wire/core/Selectors.php line 283)

#0 /home/.sites/24/site1275/web/wire/core/Selectors.php(320): Selectors->create('0', '', ':7232549db11.sq...')
#1 /home/.sites/24/site1275/web/wire/core/Selectors.php(115): Selectors->extractString('0:7232549db11.s...')
#2 /home/.sites/24/site1275/web/wire/core/Selectors.php(104): Selectors->setSelectorString('0:7232549db11.s...')
#3 /home/.sites/24/site1275/web/wire/core/Pages.php(213): Selectors->__construct('0:7232549db11.s...')
#4 [internal function]: Pages->___find('0:7232549db11.s...', Array)
#5 /home/.sites/24/site1275/web/wire/core/Wire.php(397): call_user_func_array(Array, Array)
#6 /home/.sites/24/site1275/web/wire/core/Wire.php(332): Wire->runHooks('find', Array)
#7 /home/.sites/24/site1275/web/wire/core/Pages.php(320): Wire->__call('find', Array)
#8 /home/.sites/24/site1275/web/wire/core/Pages.php(320): Pages->find('0:7232549db11.s...', Array)
#

I dont know if the error exist only after the last upgrade or if it occured earlier.

What does this error message means?

Link to comment
Share on other sites

@Juergen
Thanks for reporting. You cannot open or restoring a backup from CronjobDatabaseModule but in ProcessDatabaseBackups which is a module made by Ryan. I couldn't  reproduce your error in PW 2.6.21. You maybe could post a new topic in general support forum. Some more information would be helpful: is CronjobDatabaseBackup still doing its job? Could you try to restore from a backup created in the 2.6.21 environment? Thanks.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...