Custom field - backup all your content with just one click

Hi I tried it and it failed :frowning: I installed the plugin as described in the readme (btw. making it possible to set it up as a Git submodule would be great) and want to use it with Kirby 2.2.1. But nothing happens when I click “create backup” in the panel. Instead I only get a JS error:

Edit I found out that I was still at 2.2.1. After updating to 2.2.3 the JS error disappears but now when I click on “create backup” the dashboard page opens … strange …

####I don’t know - I work with Kirby 2.2.3 and that works fine for me;

Previous versions of Kirby broke most of the plug-ins, so I decided to re-create this plug-in for Kirby 2.2.3 and higher only.

See my screenshot; in my case it’s working fine. Did you change the .htaccess file in /backup/ to match your own domain? You can also delete it / reload / see if it works than (the file is there to prevent hot-linking - but backup should work without it).

- edit - I updated the Git-source with a new .htaccess and other adjustement - maybe this helps? (don’t forget to write down your domain in that file; it’s “localhost” right now).

- edit 2 - Tested it on both localhost and productionserver; it works (with Kirby 2.2.3 at least). Let me know if you discover any troubles. The zipped-content-file will be stored in /backup - so you should see it there…

1 Like

Whoohoo :slight_smile: Works now on my localhost. Will test it on server later … Thank you very much!

When you migrate it to another server, just replace localhost in .htaccess to (a part of) your domainname.

You can use wildcards * to enable it on both your main-domain and sub-domains and / or other .TLD’s (.com / .de / etc…).

Just checkout the .htaccess for detailed instructions.

Hm … on the server the ZIP is generated but when I try to download it I get an “Internal Server Error” (500). I change the line in the .htaccess to

RewriteCond %{HTTP_REFERER} !.*rudolphlab.com.* [OR]

The domain is rudolphlab.com and the backup link is like http://rudolphlab.com/backup/2016-04-09_12-12-45__rudolphlab_com__XXXXXXXXXXXXXXXX.zip. Any idea why this won’t work?

No idea… maybe just delete / disable the .htaccess for another test?

I work with both XAMPP and Apache - that works fine.

Or change the rule to

RewriteCond %{HTTP_REFERER} !.*rudolphlab.* [OR]

The .htaccess only prevents hotlinking - but the filename is not very easy to guess, so you can try without.

The rule above allows linking form all subdomains from rudolphlab and all .tld's (but only when they know the exact address of the .zip).

And it’s always safer to download / delete the .zip after creation…

Omitting the .com doesn’t help. But it works fine without the .htacces and the more ore less cryptic links are secure enough for me :smiley:

Cool - but sad to hear it doesn’t work on your server…

500-errors are very common, I never know why they are triggered :slight_smile:

Maybe there is an error.log?

You can also prevent hotlinking with an other syntax in your .htaccess - but I did find this one on StackOverflow and decided to use it (it was working with all my sites / server).


But like you said - the link has a random number at the end, generated with every back-up. Security by obscurity is not very good practice, but when you delete the file after download, it should do the trick :stuck_out_tongue:

- edit -

I forgot - some servers do not allow extra protection of the .htaccess file it self (they trigger an 500 error when doing so).

That’s why I commented these options in the new .htaccess file;

#################################################################################################

# Protect this .htaccess file

# <files .htaccess>
#  order allow,deny
#  deny from all
# </files>

#################################################################################################

# Directory browsing disabled

# Options All -Indexes

#################################################################################################

# If your domainname is www.yourdomain.com change the hot-linking prevention at line #30
# to something like this: RewriteCond %{HTTP_REFERER} !.*yourdomain.com.* [OR]

<IfModule mod_rewrite.c>

RewriteEngine on

# Prevent downloads, requested without a valid referer

RewriteCond %{REQUEST_URI} \.(zip|php)*
RewriteCond %{HTTP_REFERER} !.*localhost.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) http://%{REMOTE_ADDR}/$ [R=301,L]

</IfModule>

#################################################################################################

Hm … thats even more strange: The new .htaccess results in this:

It’s looking for dollars and can’t find them… $ in the URI :slight_smile:

Lol - no idea… maybe because you point to an ip-address in stead of a dedicated domainname?

Actually I din’t point nowhere :wink: When clicking on the download I can see the correct download link flashing in the address bar but somehow it is redirected to this rather strange IP link … don’t know why …

It’s the ip-range from telefonica.de - https://db-ip.com/77.8.116.83

Maybe it’s the ip of your real domain?

…or maybe you are running the .htaccess with your domainname locally?

So the localhost is searching for the .zip file locally, but it’s redirected to your real server?

Yes Telefonica is my local internet provider but I tried to run it from the server … however. It works without the .htacces and I’m happy with that :slight_smile:

Cool - I think the hot-linking stuff causes the trouble.

Most content is downloadable from the front-end of your site, so why bothering about downloading it from /backup :stuck_out_tongue:

Indeed … that’s what I thought, too :slight_smile:

Hey there!
I’m very interested in your plugin but for a slightly different use case than the one it was built for. I would love some advice on which direction you think I should take!

Instead of backing up the whole content folder from the dashboard (site.php blueprint), I’d like it to be able to backup one page (and subpages). What I’ve though of so far:

  1. Add the field in the blueprint. Easy enough.
  2. Change the folder to backup in the backup.php file (line 102)
  3. And I got stuck at number 2!

How would I go about passing the url of the page I’m editing to be the folder to backup?

Cheers!
Math

Just tried this plugin on my testserver, and while it seems to create a backup file on the server, I get an internal server error for the path http://mydomain.com/content-backup/ and the plugin stops, so it never shows the completed backup.

Also, it doesn’t recognize the backup file, probably because it’s no valid zip file, its extension is .zip.bVJwwv– looks like an intermediate state?

Maybe kirby doesn’t have write access to the content-backup folder? What’s the chmod on the folder?

There is no real folder “content-backup”, I think it’s a custom Kirby Route…