Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
18 posts Page 1 of 2
A simple way to add a link in the admin panel sidebar to allow your client to easily take a backup of their site data using gen_dump.php

Create a template called backup.php - change written content as you wish!

Code: Select all
<?php require_once( 'admin/cms.php' ); ?>
<cms:template title='BACK UP your DATA!' clonable='0' access_level='7' commentable='0' order='999' >
<cms:editable name='back_up_info' type='message'  order='910'>
<br><br><p><strong>When you have applied updates to your site via the CMS it is a good idea <span style="color: #FD7303;">to BACK UP your data.</span></strong></p><br>
<p>Click <strong>'View'</strong> to go to the <strong>BACK UP page</strong> (it'll take less than 1 minute)!</p><br>

<cms:embed 'doctype.html' />
... your bits & pieces here ...

<style type="text/css">

h1 {
     color: #222;
     font-size: 24px; 
     padding: 0;
     margin: 0 0 15px 0;

h2 {
     color: #222;
     font-size: 18px; 
     padding: 0;
     margin: 0 0 15px 0;

a.back-up-link  {
   display: block;
   color: #FFF;
   font-size: 20px;
   background-color: #B0D1F6;
   background: #FD7303;
   padding: 10px;
   margin: 20px 0 40px 0;
   text-decoration: none;
   text-align: center;

a.back-up-link:hover {
   color: #333;
   background: #FD7303;

<div class="container">
      <div class="row">
         <div class="col-sm-6">   
            <h1>Backup your data!</h1>
               <a class="back-up-link" href="<cms:show k_admin_link/>gen_dump.php">&raquo;&raquo; CLICK HERE TO BACK UP NOW!</a>

            <h2>BACK UP INSTRUCTIONS</h2>                  
                     <li>click on the backup link above</li>
                     <li>a dialog box will pop up - select 'save file' (not 'open with');</li>
                     <li>then click OK;</li>
                     <li>a file called <i>install-ex.php</i> containing your database data will be saved in the default folder on your computer - most likely the 'downloads' folder;</li>      
                     <li>if there is already an install-ex.php file from a previous back up, the newly downloaded file will be called something like install-ex(1).php, install-ex(2).php;</li>      
                     <li>you can move the  <i>install-ex.php</i> file to another folder and keep the last 2-3 back up files;</li>

             </div> <!-- /col -->
         <div class="col-sm-offset-1 col-sm-5">

            <h2>Keep copies ...</h2>
            <p>Please ensure that you keep a copy of anything you upload to your site e.g. images, pdf documents.</p>
            <h2>A bit of background about backing up ...</h2>
            <p>A webhost will have duplicate servers and take server back ups to ensure they provide a reliable and secure service. BUT, this doesn't necessarily include taking a back up of an individual client's database(s). In the unlikely event of something going wrong with your database it could be restored via the webhost, but this would be likely to take at least 2 days and several phone calls to the help desk.</p>
            <p>Far better to be self-reliant and have a back up plan of our own. We can implement our plan without delay if the worst should happen - very unlikely, but you never know!</p>
             </div> <!-- /col -->
       </div> <!-- /row -->
</div> <!-- /container -->

<cms:embed 'scrollup.html' />
<?php COUCH::invoke(); ?>

This gives you a link in the sidebar - "BACK UP your DATA!" - clicking on that shows this:
backup-screenshot1.jpg (40.78 KiB) Viewed 5150 times

Click on View:

backup-screenshot2.jpg (60.33 KiB) Viewed 5150 times

Adapt to your needs. Any comments or suggestions welcome!
Thanks @potato for sharing that.

I've said this before to you - the kind of details you put into the admin-panel to help your client is just amazing :)
This is simply amazing, thank you so much.

Great job!
Thanks potato !

This is awesome !! Thanks for sharing. :D
Thank You so much.

Just Awesome!!!
where innovation meets technology

I also want to know the procedure of restore.

This trick cleverly uses the utility for migrating a site from development to production as a backup utility. To restore a backup, you would use the same method as for deploying a new site. ( ... erver.html)

First you would completely clear the corrupted database: delete all of the tables.

Place the install_ex.php file in the site's couch folder.

Access the couch folder in a browser ( and provide super admin credentials just as if you were installing a new site. Couch will notice the install_ex.php file and use it to rebuild the database.
Thanks @Tim , for the information.

But It display a error

Where I had already delete db and create New One DB with same name.


@Subhamoy, Good thing you tested this first. You are just testing, right?! :shock:

You say you deleted the database, but the error says different. I think you must have made some mistake. Maybe you...
Deleted the wrong database?
Restored it to the wrong site?
Emptied the tables but didn't delete them?
Didn't really remove the old database?

Open phpMyAdmin on the server. Select the database in the sidebar. Go to the bottom of the list and choose "Check All". From the dropdown menu choose "Drop" (in database language, this means delete). Now visit the site and the installation should go ahead normally.

You don't have to delete the database, just remove all the tables.

Warning: If you use a prefix to keep multiple Couch installations in the same database, be sure you remove only the right set of tables. Don't accidentally delete the other Couch sites in the database.

By the way, you can also backup or migrate the database using phpMyAdmin. Use the 'Export' tab to make a backup and the "Import" tab to restore or install the database.

I hope this helps to solve your problem. Otherwise, I'm sure KK will step in and save the day. :)


18 posts Page 1 of 2

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 2 guests