Giter Site home page Giter Site logo

kirby-backup-widget's Introduction

Kirby Backup Widget

Kirby panel widget to easily backup your site content.

version kirby_version license

license

Installation

Use one of the alternatives below.

1. Using kirby-webpack

Simply use the built-in Kirby Package Manager by running:

$ npm run kirby:add
$ [?] Git URL: https://github.com/arnaudjuracek/kirby-backup-widget
$ [?] Module name: kirby-backup-widget
$ [?] Category: widgets

2. Kirby CLI

If you are using the Kirby CLI you can install this plugin by running the following commands in your shell:

$ cd path/to/kirby
$ kirby plugin:install arnaudjuracek/kirby-backup-widget

3. Clone or download

  1. Clone or download this repository.
  2. Unzip the archive if needed and rename the folder to kirby-backup-widget.

Make sure that the plugin folder structure looks like this:

site/widgets/kirby-backup-widget/

4. Git Submodule

If you know your way around Git, you can download this plugin as a submodule:

$ cd path/to/kirby
$ git submodule add https://github.com/arnaudjuracek/kirby-backup-widget site/widgets/kirby-backup-widget

Options

The following options can be set in your /site/config/config.php file:


widget.backup.include

c::set('widget.backup.include', ['projects', 'blog']);
  • description: array of folders to include from the backup. Note that if you use widget.backup.exclude, all folders will be included no matter what you set in widget.backup.include.
  • default: by default, all folders inside content/ are included

widget.backup.exclude

c::set('widget.backup.exclude', ['error']);
  • description: array of folders to exclude from the backup. Note that if used, widget.backup.include will be ignored.
  • default: []

widget.backup.include_site

c::set('widget.backup.include_site', false);
  • description: whether to include root files and site options. Set this to true if you want to backup your site.LANG.txt etc.
  • default: false

widget.backup.destination

c::set('widget.backup.destination', 'backups');
  • description: set the destination directory for the backup files. Accept subdirectory by using 'dir' . DS . 'subdir'. Note that the directory will be placed in content/ no matter what. This is mainly used to avoid collisions if you already have a directory called backups in content/. If the directory does not exist, it will be automatically created with CHMOD 0777. Finally, note that this backup directory will always be exluded, to avoid recursion.
  • default: backups

widget.backup.overwrite

c::set('widget.backup.overwrite', true);
  • description: set it to false if you don't want to allow backups overwrite. If set to false and a backup file with the same name already exists, the widget will show an alert error message.
  • default: true

widget.backup.date_format

c::set('widget.backup.date_format', 'Y-m-d');
  • description: set the date format used to name the backup file. See function.date.php for available formats.
  • default: Y-m-d

Security

It is recommended to limit access to your backup files by placing them behing a firewall.

Here is a quick way to prevent unauthorised user to download your backups :

config.php
c::set('routes', [
  [
    'pattern' => 'content/backups/(:any)',
    'action' => function ($file) {
      if (site()->user()) {
        // only logged users have access to content/backups files
        page('backups')->files()->find($file)->download();
      } else {
        header::forbidden();
        die('Unauthorized access');
      }
    }
  ]
]);
.htaccess
# block backups from being accessed directly
RewriteRule ^content/backups/(.*)$ index.php [L]

If you want more detail about it, see how to build an asset firewall.

Todo

  • change basic url ?action= parameters for a more robust widget routing solution
  • add confirmation modal before deleting
  • swtich to .gitignore like exclude / include path patterns

Requirements

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.

kirby-backup-widget's People

Contributors

arnaudjuracek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kirby-backup-widget's Issues

Short Tags

The widget uses 'Short Tags' so will not work on systems where this has not been enabled.

include site option not working in multi-lang site

The option to include site settings in the export is great but is limited.
Multi lang site.en.txt files are "forgotten" and it looks like files attached to the settings page are ignored...

if (c::get('widget.backup.include_site', false)) $files[] = 'site.txt';

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.