Custom field - backup all your content with just one click

There seems to be a backup folder in the github repo and it should be included. See from the instructions over on github

INSTALLATION

  • Download the .zip and extract it to the root of your site.
  • See \site\blueprints\site.php for the basic set-up.
  • Change the domainname in \backup\.htaccess to your own.

In the zip there’s clearly a backup folder that will sit at the root of your site.

Yes, there is a backup folder with an .htaccess in it, but “content-backup” is a route, not a folder.

Indeed, I went too fast over the code.

Sorry for the late reaction; I created this plug-in using a different (Kirby) username, so I wasn’t mentioned.

Are there still issues with the plug-in?

I’ve added it to about 10 sites (Kirby 2.3) and it works like a charm.

Maybe the blueprint must be renamed from .php to .yml - but I’m not sure that’s the issue.

1 Like

That “second” extension is not set by the plug-in… maybe this is server related?

Does it work on a localhost (pc / Mac, etc…) or not?

Blueprints can have both extensions, .php or .yml (.yaml), and you can even mix them, the only difference is that if you use .php, you need to add this line at the top of your blueprints:

<?php if(!defined('KIRBY')) exit ?>

Cool - didn’t know that.

I will update this info for another plug-in I just made.

Nope, unfortunately I get the same error when using it locally.
I already tried your suggestion with disabling the .htaccess file, but still no luck.

Seems like Kirby is not able to access this custom route /content-backup/ ?

Trying your plugin and when I click on the button to start a new backup, it just spins forever.

What I did to install it on my localhost:

git cloned the repo to the root of my kirby-website
— copied backup folder from kirby-website/kirby-backup/site/fields/backup to kirby-website/site/fields
—copied field from the blueprint in kirby-backup/site/blueprints to my site.php blueprint
— since I am testing it on my localhost I did not change the domain in the plugin’s .htaccess

My content folder is about 28mb, nothing huge. Running kirby 2.3.1.

What did I do wrong?

Looks like you forgot to put the backup.php file from /site/plugins into the same folder of your installation?

I can’t check it right now - but when it’s a JS-error, you can check the console.

It may throw up there.

Also there was at least one report where the plug-in wasn’t working, due to the .htaccess settings.

Yes I missed that part.

Now it works but it’s throwing this error right after I click on the backup button (within the panel).

Warning: ZipArchive::close(): Failure to create temporary file: No such file or directory in /Users/name/Sites/website/site/plugins/backup/backup.php on line 149

Warning: filesize(): stat failed for backup/2016-10-23_11-39-35__fulvioosti_dev__65FnVeX3OKoBQQ4R.zip in /Users/name/Sites/website/site/plugins/backup/backup.php on line 151
Last backup created on : October 23, 2016 - 11:39:35 (n/a).

I have the feeling I still did not copy something necessary for the plugin to work.

That error is created by your server, not the plugin.

Or, well… of course it’s the plugin-code that does trigger this error but it occurs on server-level :slight_smile:

It looks like it can not create the .zip-file, containing the back-up?

Maybe you don’t have the right permissions set on the /backup folder.

It was one of my first plugins, not the best code - sorry for that…

By the way, maybe you can delete the exact path to the file in your post? It contains information that can be mis-used (username, folders, path, etc…).

When all went good, this file must be available on your server;

/backup/2016-10-23_11-39-35__fulvioosti_dev__65FnVeX3OKoBQQ4R.zip

But the filename is different, everytime you hit the “backup” button.

Thanks for the security tip!

I should have simply renamed the folder plugin from kirby-backup to backup.

Pretty noob, but I suggest you to write a more explanatory readme.md! (I can push a pull request if you don’t mind) :smiley:

You assumed a couple of steps in the procedure to install the plugin that threw me off, even though they might be a common procedure when installing a kirby plugin.

Anyway, it works perfectly.

What’s the best way to localise it, except for translating (replace) the texts in a different language?

About the localisation… I don’t know :slight_smile:

This was one of my first project regarding Kirby, and I am not very proud
of it (the code isn’t that good…).

I made it, because I wanted (and so did my client[s]) to be able to backup
/ download all content with the single click on a button.

But I did not write very good code… languages / functions / etc… are
all mixed - sorry for that.

The best way to localize is to edit the code yourself, I guess… or use
variables form an array?

$text = array();

$text[0] = “back this up”;
$text[1] = “delete it?”;

And use this in the code, where the original text appears, like this;

<?php echo $text[1]; ?>

(I am writing this from my phone, so no nice encoding here, sorry).

When you safe the text in a seperate file, make the $text global and
include it with include_once (“my_text.php”); you can “easily” parse the
text dynamically.

Yes no problem I’ll have a look at the docs also.

I think this plugin is quite important, I had the same client request so it’s something needed. And I’ll start to use it for my personal website as well I think.

Good work!

Content-export is verry important, indeed - every CMS I know / use have the options to export it.

Of course you can download / .zip the contents-folder using FTP or a CronJob - but this plugin does automate it a little.

You are free to alter the code, fork it and make a better version :slight_smile: