Cockpit: [Proposal] Support a easy process for Backup and Restore

Created on 24 Feb 2018  路  10Comments  路  Source: agentejo/cockpit

Hey Cockpit team,

based on the experience on other CMS, I think Cockpit can benefit if provides a simple mechanism to export/import configurations (e.g. collection definitions, global settings) and contents (e.g. collection contents, user accounts, etc..).

For what I understood and it seems to work if I copy (in below example assuming that I am using sqlite):

config/config.yaml
storage/collections
storage/data
storage/uploads

I can basically copy all the configurations and contents to another instance of cockpit, however, I think that this process is not error proof (copy of storage/data must be performed when there are no sqlite accesses) and not user-friendly.

What do you think?

  • Having an addon that performs a global backup/restore is a good idea?
  • Or instead, having a CLI tool?
  • Should we separate concept of configurations and contents?

Thanks
Paulo

Most helpful comment

@pauloamgomes I think this is a great idea, do you want to step in and work on one?

All 10 comments

@pauloamgomes I think this is a great idea, do you want to step in and work on one?

Sure @aheinze

Great, thanks @pauloamgomes !

Hey @aheinze , as discussed I'm working on it, think I'll have a near-final version soon, I have only one doubt that maybe you can help. In the particular case (using sqlite) that we drop a collection:

$this->module("collections")->removeCollection($name);

then I recreate

$this->module("collections")->createCollection($name, $collection);

above works well, collections are recreated, but if in the same request if I try to save some entries:

$this->module('collections')->save($collection['name'], $entries);

it seems that the structure is not updated in the sqlite!! (I can also confirm that by accessing directly the sqlite file, the tables are not yet there, but after a new request, they are created)

Any ideas?

Thanks in advance
Paulo

btw, some examples how it looks now:

Backups page
Backups view

Backup view
Backup

Restore view
Restore

Resuming a backup is a zip file organized using yaml and json files:

Structure

@pauloamgomes first let me thank you for your work on this add-on, looks great! As I undesrtand it right, you're creating an own meta backup format. why don't you just back up and restore the files, wouldn't it make things much easier?

Hey @aheinze , you mean by files the collections/regions/forms that are saved in form of php, right?
Question is that I wasn't sure if just restoring those files and then saving the entries it was enough, and instead of that I'm using your storage methods to delete and create definitions (colections, regions, forms) and add contents.

My intention is to have enough flexibility to support different scenarios, e.g.:

  • Backup only collection definitions and restore on other instance
  • Backup just the entries and restore on other instance (without erasing the current ones), so the entries will be added
  • When restoring entries they should work as before (e.g. if collectionlink field type is used should refer to the correct entry)
  • Backup everything and restore again erasing all existing data

Right now I solved the issue that mentioned before by executing the restore functions in different ajax requests, so a backup/restore seems to work well, but happy to do any change based on your thoughts. I plan to release it soon so hope you can review it.

I see, looking forward to your final result!

cool @pauloamgomes ! I'll take a look. Thanks for your work!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

poldixd picture poldixd  路  4Comments

RoelantStegmann picture RoelantStegmann  路  4Comments

desvu picture desvu  路  3Comments

elpeyotl picture elpeyotl  路  3Comments

gryphonmyers picture gryphonmyers  路  6Comments