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
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
- Clone or download this repository.
- 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/
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
The following options can be set in your /site/config/config.php
file:
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 inwidget.backup.include
. - default: by default, all folders inside
content/
are included
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:
[]
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 yoursite.LANG.txt
etc. - default:
false
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 incontent/
no matter what. This is mainly used to avoid collisions if you already have a directory calledbackups
incontent/
. If the directory does not exist, it will be automatically created withCHMOD 0777
. Finally, note that this backup directory will always be exluded, to avoid recursion. - default:
backups
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
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
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 :
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');
}
}
]
]);
# 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.
- 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
- Kirby 2.0+
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.
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.