Jump to content
kixe

Cronjob Database Backup

Recommended Posts

@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

Share this post


Link to post
Share on other sites

Many thanks. It installs fine now. When I go to the settings page I get this notice:

Notice: Undefined index: cycle in /home/sitename/public_html/beta/site/modules/CronjobDatabaseBackup/CronjobDatabaseBackup.module on line 165

Share this post


Link to post
Share on other sites

@Marty Walker
Thanks for your debugging help. Everything fixed.

  • Like 1

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites

It would be great if I could set the maximum number of backups created by this module I want to keep. :-)

  • Like 2

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

I was half way through trying to write this when I found your module. Thank you thank you thank you :D. Made really quick work of an important feature. 

Share this post


Link to post
Share on other sites

@MuchDev
Thanks!
Try it!
Like it!
Mark it as favorite in the modules directory! ;)

@ceberlin
I put it on the todo list.

@netcarver
Good remarks I will add your code soon.

  • Like 1

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Thank you so much! Managing those backups has been a little bit of a pain, now the pain is gone. Nice touch with the cleanup, 20 backups cleaned out :). This module is indispensable now. 

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
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...

Share this post


Link to post
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:

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      2019-10-18
      2019-08-08
      2019-06-15
      2019-06-02
      2019-05-25
      If you are interested, you can test the current state of development:
      https://github.com/gadgetto/SnipWire
      Please note that the software is not yet intended for use in a production system (alpha version).
      If you like, you can also submit feature requests and suggestions for improvement. I also accept pull requests.
      ---- INITIAL POST FROM 2019-05-25 ----
      I wanted to let you know that I am currently working on a new ProcessWire module that fully integrates the Snipcart Shopping Cart System into ProcessWire. (this is a customer project, so I had to postpone the development of my other module GroupMailer).
      The new module SnipWire offers full integration of the Snipcart Shopping Cart System into ProcessWire.
      Here are some highlights:
      simple setup with (optional) pre-installed templates, product fields, sample products (quasi a complete shop system to get started immediately) store dashboard with all data from the snipcart system (no change to the snipcart dashboard itself required) Integrated REST API for controlling and querying snipcart data webhooks to trigger events from Snipcart (new order, new customer, etc.) multi currency support self-defined/configurable tax rates etc. Development is already well advanced and I plan to release the module in the next 2-3 months.
      I'm not sure yet if this will be a "Pro" module or if it will be made available for free.
      I would be grateful for suggestions and hints!
      (please have a look at the screenshots to get an idea what I'm talking about)
       




    • By eelkenet
      Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild.  
       
      What is it?
      The missing range slider Inputfield for Processwire. 
      What does it do?
      This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates.
      It includes a visible and editable value field, to override/tweak the value if required.  
      Features
      Min/max values Precision (number of decimals) Steps (Read more) Manual override of the selected value (will still adhere to the rules above) Usage
      Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo
      A field with Min=0, Max=1, Step=0.2, Precision=2

      Field with settings Min=0, Max=200, Step=0.25, Precision=2

       
      Todo
      Make the display-field's size configurable (will use the Input Size field setting)  Hopefully become redundant If it's usable for others I'll add it to the Modules list  
      Changelog
      v002
      - Fix issue where setting the step value to an empty value created problem with validation
      - Make the display-field optional 
      v001
      - Initial release
       
      Thanks!
       
       
    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
×
×
  • Create New...