# Custom field - backup all your content with just one click

**URL:** <https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307>\
**Category:** Plugins\
**Tags:** discontinued\
**Created:** [October 24, 2015, 3:03pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307 "2015-10-24T15:03:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon68757951](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@anon68757951](https://forum.getkirby.com/u/anon68757951)\
**Post date:** [October 24, 2015, 3:03pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/1 "2015-10-24T15:03:35Z")

</div>

**Edited by @texnixe on 2016/07/02** : The repo currently has its home here: [https://github.com/1n3JgKl9pQ6cUMrW/kirby-backup](https://github.com/1n3JgKl9pQ6cUMrW/kirby-backup)

* * *

I know the content of a Kirby site is easy to backup, by simply dragging the folder from the server to your local system.

###Why a backup function?###

But my client wanted an _even more easy_ workflow, for backing-up all his / her files (text / images), without the need to struggle with sFTP-accounts, Dropbox-sync, etc…

He was used to Wordpress, which has a default **file-revision** function (_you can track all the changes made in your text, from within the panel and roll back if needed_).

So I created a **[custom field](https://github.com/dmotion/kirby-backup)** which allows you to back-up the complete `\content` folder with one click on a button…

###How it works###

* * *

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/a/abcf8d051c489f70607d297e2a8b86687a6be8af.gif)

* * *

**[Download the plugin](https://github.com/dmotion/kirby-backup)** from my Github page - and be sure to check the `readme.md` file before using it.

* * *

### Is it secure?###

**I tried to secure this new function as best as possible;**

- Only one .zip-file is created at most (older files are automatically deleted).
- The .zip-file has an unique, random file-name (preventing direct downloads).
- The backup-creation script must be called from the same server - direct access is forbidden.
- Only POST-requests are valid - and must match some standard syntax-settings.
- Hot-linking to every file in the `\backup\` directory is forbidden.
- A .htaccess file in the `\backup\` directory secures all actions and files.
- After creating and downloading the .zip (which contains all the content) you can delete the original at once.
- etc…

###Please, report any bugs###

I do realize this extra feature can introduce a new attack-vector (like all functions on a website can)…

…so I hope someone will check the **[source-code](https://github.com/dmotion/kirby-backup)** and do a basic security audit on it (_just to be sure, in order to prevent leaks I did not see myself_).

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [October 24, 2015, 4:14pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/2 "2015-10-24T16:14:45Z")

</div>

Why do you use an external script? You could also implement this using a route in a plugin. This would make it possible to check for user permissions and if a user is even logged in.

I think that this is a great idea in general, but I wouldn’t recommend using it with the external script. It’s very easy to fake the Referrer header. 😉

---

<div class="post-metadata">

**Author:** ![anon68757951](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@anon68757951](https://forum.getkirby.com/u/anon68757951)\
**Post date:** [October 24, 2015, 4:18pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/3 "2015-10-24T16:18:48Z")

</div>

I know it’s easy to fake the header, but I decided it’s better than nothing (also, the `.htaccess` restricts all access).

I only know Kirby for a week now… so I’m adopting the best way to create things like this…

I’ve read about routing and user-permissions, but I’m not sure how to create your own “route” with a plug-in structure.

**More suggestions are welcome!**

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [October 24, 2015, 4:34pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/4 "2015-10-24T16:34:43Z")

</div>

> [@dMOTION](#):
>
> also, the .htaccess restricts all access

Well, no. It doesn’t at all if you fake the headers. You could currently access the PHP file with a faked header to create a backup and then download the ZIP also using a faked header.

BTW: Another backup solution that comes to my mind is the [Git-commit-and-push-content plugin](https://forum.getkirby.com/t/git-commit-and-push-content/2087). You can use that to create a backup on a remote Git server in the same moment any content is changed in the Panel.  
I know that this isn’t as easy as downloading a ZIP, but on the other hand users won’t need to do anything manually.

---

<div class="post-metadata">

**Author:** ![anon68757951](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@anon68757951](https://forum.getkirby.com/u/anon68757951)\
**Post date:** [October 24, 2015, 4:53pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/5 "2015-10-24T16:53:41Z")

</div>

I will check out the plug-in routing option, that seems more secure.

Most clients don’t have / want a Github account for back-ups - so I really need a simple solution 😄

The script isn’t live on any server - it’s just a try-out and I will update it with the routing option first.

Of course you can already download a complete site with a tool like **[Httrack](https://www.httrack.com/)**, so the script itself does not open any doors that should be closed 😛

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [October 24, 2015, 5:35pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/6 "2015-10-24T17:35:39Z")

</div>

That depends on what your content directory contains. 😉  
It might as well contain password-protected data.

---

<div class="post-metadata">

**Author:** ![anon68757951](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@anon68757951](https://forum.getkirby.com/u/anon68757951)\
**Post date:** [October 25, 2015, 1:03pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/7 "2015-10-25T13:03:09Z")

</div>

Okay, so I made **[my first Kirby plugin](https://github.com/dmotion/kirby-backup)** ever, with a custom route and a security check on the user (so you can’t create a backup, if you’re not logged in / registered as an user).

###And I did fine-tune some things;###

- The file size of the backup is shown.
- The backup file contains the domain-name (which can come in handy, when backing up several domains).
- The option to delete a backup is now recommended in the text (for security reasons).
- Fixed some typos.
- etc…

![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/d/d8f1bd48c144624540c83d4f0be0666ddb7773be.png)

* * *

I guess this new version offers a more secure way for creating, downloading and maintaining your sites content - let me know in the comments.

###POST vs. GET using a custom route###

But I do have one question; the backup-script (located in `site/plugins/backup/backup.php`) is called from the panel, using an AJAX-call (triggered from `site/fields/backup/backup.php`).

Basically, this AJAX-calls request a page, using a route, which is defined as `sitename/content-backup/?action=create`.

This works fine, as long as I use a GET-parameter for the AJAX-call… but I prefer a POST-parameter - so you can’t see / sniff the variables used in the URI.

A POST-call returns a `404 - page not found` in my developers console, while a GET-call does work… any idea why I can’t use a POST-method here?

It’s not a big issue, I guess - but it’s my first plugin (and first script using Kirbies route-option), so maybe I’m doing something wrong?

The route-option is declared in `site/plugins/backup/backup.php`.

###Direct links to these files###

1. **backup.php** - [https://github.com/dmotion/kirby-backup/blob/master/site/plugins/backup/backup.php](https://github.com/dmotion/kirby-backup/blob/master/site/plugins/backup/backup.php)
2. **backup.js** - [https://github.com/dmotion/kirby-backup/blob/master/site/fields/backup/assets/js/backup.js](https://github.com/dmotion/kirby-backup/blob/master/site/fields/backup/assets/js/backup.js)

* * *

###Update - version 0.0.3###

**[Updated](https://github.com/dmotion/kirby-backup)** the little rascal with an option to show all backupped files after the creation of a backup.

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/7/77d10d3d04ebcc85828fbaed9d465b643783ac38.png)

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [October 25, 2015, 8:09pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/8 "2015-10-25T20:09:55Z")

</div>

The reason `POST` does not work is that [routes only listen for `GET` requests by default](http://getkirby.com/docs/advanced/routing#methods). You can use `'method' => 'POST'` to only allow `POST` requests.

Since your code is a bit hard to read (no indentation), I can’t really tell whether it is secure or not.

---

<div class="post-metadata">

**Author:** ![anon68757951](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@anon68757951](https://forum.getkirby.com/u/anon68757951)\
**Post date:** [October 26, 2015, 10:44am UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/9 "2015-10-26T10:44:51Z")

</div>

Thanks for the helping hand.

The docs at Kirby are outstanding documented - but sometimes it’s hard to find a specific settings / variable / option for my issues… (but I think that’s my problem only).

Glad you helped me out with the POST option, **[I updated the plugin](https://github.com/dmotion/kirby-backup)** - and also restored the original indentation;

I used a default indentation of 2 spaces, but something went wrong copy/paste the codes into GitHub (_I don’t use a client to push the codes - just a simple copy/paste because I do a lot of editing from my tablet and I don’t want a GitHub client installed on that device_).

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [October 26, 2015, 11:50am UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/10 "2015-10-26T11:50:29Z")

</div>

Yes, that’s true. We are currently working on the documentation to improve the structure.  
Do you have any specific feedback on the routing page? Where did you look for it/expect it?

---

<div class="post-metadata">

**Author:** ![anon68757951](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@anon68757951](https://forum.getkirby.com/u/anon68757951)\
**Post date:** [October 26, 2015, 12:15pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/11 "2015-10-26T12:15:21Z")

</div>

I don’t have any specific feedback, so I can’t help you out 😄

My experience is that literally every little detail of Kirby (API) is documented on this site, but sometimes hard to find (sometimes it even looks like Google can’t index the content very well? Both for the forum as the docs-section… even a search with “site:forum.getkirby.com IamLookingForThisKeyWord” do not always return proper results).

Once I know the solution (like the POST / GET toggle for the routing-option) it’s easy to find it on the site - but I could not find it, before I knew the existence of this option…

Maybe it’s a good idea to include more “complete” samples, from real live situations - so you can (as a starting Kirby addict) find and re-use code-blocks, without jumping from page to page, helper to helper and API-option to… API-option?

* * *

_I also have another issue (overriding the default settings for a number-field) but I’ll post that in a new threat, in order to keeps things clean and separated._

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [October 26, 2015, 12:20pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/12 "2015-10-26T12:20:04Z")

</div>

> [@dMOTION](#):
>
> Maybe it’s a good idea to include more “complete” samples, from real live situations - so you can (as a starting Kirby addict) find and re-use code-blocks, without jumping from page to page, helper to helper and API-option to… API-option?

That’s what we are currently trying to do. Stay tuned. 😉

---

<div class="post-metadata">

**Author:** ![tobiasweh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tobiasweh/32/13376_2.png) [@tobiasweh](https://forum.getkirby.com/u/tobiasweh)\
**Post date:** [November 20, 2015, 1:29pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/13 "2015-11-20T13:29:04Z")

</div>

Does anyone know what happened to this plugin? The Github project isn’t available anymore and dMotion isn’t a user here anymore …

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 20, 2015, 1:31pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/14 "2015-11-20T13:31:08Z")

</div>

@dMotion has changed his username, now he is @1n3JgKl9pQ6cUMrW

The repo is here: [https://github.com/1n3JgKl9pQ6cUMrW/kirby-backup/blob/master/site/plugins/backup/backup.php](https://github.com/1n3JgKl9pQ6cUMrW/kirby-backup/blob/master/site/plugins/backup/backup.php)

---

<div class="post-metadata">

**Author:** ![tobiasweh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tobiasweh/32/13376_2.png) [@tobiasweh](https://forum.getkirby.com/u/tobiasweh)\
**Post date:** [November 20, 2015, 1:44pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/15 "2015-11-20T13:44:00Z")

</div>

Thanks 🙂 that’s good news!

Do you also know which Plugin is used to get the tabbed site options?

---

<div class="post-metadata">

**Author:** ![1n3JgKl9pQ6cUMrW](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/1n3jgkl9pq6cumrw/32/2368_2.png) [@1n3JgKl9pQ6cUMrW](https://forum.getkirby.com/u/1n3JgKl9pQ6cUMrW)\
**Post date:** [November 20, 2015, 1:56pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/16 "2015-11-20T13:56:51Z")

</div>

Hi,

I did change my GitHub name, so all my Kirby-plugins are now collected at one page.

**[https://github.com/1n3JgKl9pQ6cUMrW?tab=repositories](https://github.com/1n3JgKl9pQ6cUMrW?tab=repositories)**

As we speak, I am rewriting most of the extensions - because they are not working nice with Kirby 2.2

The **backup** / **icon-field** / **tabbed-interface** are allready fixed - but I did not push them to the master; I will check them once again this weekend and will update them this weekend.

* * *

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/0/0726cc3ac25205109c5bb711af0f1e74a16ee28c.png)

### tabbed interface

* * *

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/3/38bf1a61be75f22d65f40e09ac1175909aa6e393.png)

### icon field (upper left)

* * *

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/e/e83a9e180d2afb36761154d2a618bdc2fb3f9891.png)

### content backup

* * *

Especially the last one is giving me headaches, because the Javascript-routing isn’t working…

```auto
Uncaught TypeError: Cannot read property 'match' of undefined - app.min.js?v=2.2.1:42

```

---

<div class="post-metadata">

**Author:** ![1n3JgKl9pQ6cUMrW](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/1n3jgkl9pq6cumrw/32/2368_2.png) [@1n3JgKl9pQ6cUMrW](https://forum.getkirby.com/u/1n3JgKl9pQ6cUMrW)\
**Post date:** [November 20, 2015, 2:19pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/17 "2015-11-20T14:19:25Z")

</div>

Hmmm… seems like Kirby is hooking all anchors in the panel with a nice RegEx… including the anchors I created for the backup-field… which causes the plug-in to crash, fired by Kirby.

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/f/fa8ce8cbcd889c152dcd5f25b7b58883d8fe94f9.png)

Guess I’m going to find myself a new job 😛

---

<div class="post-metadata">

**Author:** ![tobiasweh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tobiasweh/32/13376_2.png) [@tobiasweh](https://forum.getkirby.com/u/tobiasweh)\
**Post date:** [April 8, 2016, 6:28pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/18 "2016-04-08T18:28:37Z")

</div>

Hi @1n3JgKl9pQ6cUMrW, at the moment the backup-plugin seems to be unavailable. Are there plans to make it available again?

---

<div class="post-metadata">

**Author:** ![1n3JgKl9pQ6cUMrW](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/1n3jgkl9pq6cumrw/32/2368_2.png) [@1n3JgKl9pQ6cUMrW](https://forum.getkirby.com/u/1n3JgKl9pQ6cUMrW)\
**Post date:** [April 8, 2016, 7:13pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/19 "2016-04-08T19:13:36Z")

</div>

**[https://github.com/1n3JgKl9pQ6cUMrW/kirby-backupped](https://github.com/1n3JgKl9pQ6cUMrW/kirby-backupped)**

Previous version didn’t work with Kirby 2.3 - this version does… (well, at least with my set-up).

---

<div class="post-metadata">

**Author:** ![tobiasweh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tobiasweh/32/13376_2.png) [@tobiasweh](https://forum.getkirby.com/u/tobiasweh)\
**Post date:** [April 8, 2016, 7:19pm UTC](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307/20 "2016-04-08T19:19:07Z")

</div>

Great, thanks! I’ll try it tomorrow 😃

[Next page](https://forum.getkirby.com/t/custom-field-backup-all-your-content-with-just-one-click/2307.md?page=2)
