<div dir="ltr"><div>Here's the perl script I use to chop databases down.</div><div>It will grab all the txt files from the "from_folder"</div><div>create a folder under "to_folder" for each file it finds</div><div>create a folder under that folder for each db it finds</div><div>and then create a txt file of each table it finds in that folder.</div><div><br></div><div>Very useful when you only want to restore one table from a multi gig database dump.</div><div>I have it set up on a cron job to run after the db dumps are done for the night so I can easily grab any table I want.</div><div><br></div><div>Bob</div><div><br></div><div><br></div><div><br></div><div>#########################################</div><div><br></div><div>#!/usr/bin/perl</div><div>use File::NCopy qw(copy);</div><div><br></div><div>$from_folder = '/home/backup/dbbackups';</div><div>$to_folder = '/home/backup/chop';</div><div><br></div><div><span class="" style="white-space:pre">    </span># change to from dir</div><div>        chdir $from_folder;</div><div><br></div><div><span class="" style="white-space:pre">        </span># get all the files in there</div><div>        @f = <*>;</div><div><br></div><div><span class="" style="white-space:pre">    </span># make dir if not there</div><div>        if ( (-e $to_folder) != 1){ mkdir $to_folder,0755}</div><div><br></div><div>        foreach $f (@f){</div><div><br></div><div>                &log("chopping $f");</div><div><span class="" style="white-space:pre">         </span></div><div><span class="" style="white-space:pre">           </span># get file name and create dir of it</div><div><span class="" style="white-space:pre">               </span># assumes dumps end in .txt, need to change this if yours don't</div><div><span class="" style="white-space:pre">                </span></div><div>                ($f2) = $f =~ m/(.*)\.txt/;</div><div>                $curdir = "$to_folder/$f2";</div><div>                if ( (-e $curdir) != 1){ mkdir $curdir,0755}</div><div>                chdir $curdir;</div><div><br></div><div><span class="" style="white-space:pre">            </span># open and read through dump</div><div>                open FILE, "$from_folder$f";</div><div>                open DATA, ">temp.txt";</div><div>                $db="";</div><div>                while (my $line = <FILE>) {</div><div>              </div><div>                        # db found? if so create new folder</div><div>       </div><div>                        if ($line =~ /-- Current Database: `(.*?)`/){</div><div>                                $db = $1;</div><div>                                $dbdir = "$curdir/$db";</div><div>                                if ( (-e $dbdir) != 1){ mkdir $dbdir,0755}</div><div>                                chdir $dbdir;</div><div>                        }</div><div>       </div><div>       <span class="" style="white-space:pre">                    </span># new table found</div><div>       </div><div>                        if ($db){</div><div>                                if ($line =~ /-- Table structure for table `(.*?)`/){</div><div>                                        $table = $1;</div><div>                                        print "    $table\n";</div><div>       </div><div>                                        close DATA;</div><div>                                        open DATA, ">$table.txt";</div><div>                                }</div><div>                                print DATA "$line";</div><div>       </div><div>                        }</div><div>       </div><div>       </div><div>       </div><div>                }</div><div>                close FILE;</div><div>                &log("done chopping $f");</div><div>        }</div><div>        close DATA;</div><div><br></div><div><br></div><div>sub log{</div><div>        ($log)=@_;</div><div>        $timex = localtime;</div><div>        open(DATA,">>/home/backupxz1/bulog.txt");</div><div>        print DATA "$timex\t$log\n";</div><div>        close (DATA);</div><div>        print "$timex\t$log\n";</div><div>}</div><div><br></div><div>##########################################</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 10, 2016 at 10:34 AM, Chris Gebhardt - VIRTBIZ Internet <span dir="ltr"><<a href="mailto:cobaltfacts@virtbiz.com" target="_blank">cobaltfacts@virtbiz.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Richard,<br>
<span class=""><br>
On 3/10/2016 10:22 AM, Richard Sidlin wrote:<br>
> Thanks Chris. I'm sure it was these instructions that I followed and came<br>
> completely unstuck. It was probably me putting an arrow the wrong way<br>
> around!<br>
<br>
</span>Yes, computers can be quite literal.  And unlike work in Windows or even<br>
the BlueOnyx GUI, we don't get prompted with "Are you sure that's really<br>
what you want?"  "Hey, look again fella... are you still sure?"<br>
<br>
That said, I've used the process many a time with excellent results.<br>
It should work out just fine so long as you're following the exact syntax.<br>
<br>
Good luck!<br>
<span class="im HOEnZb">--<br>
Chris Gebhardt<br>
VIRTBIZ Internet Services<br>
Access, Web Hosting, Colocation, Dedicated<br>
<a href="http://www.virtbiz.com" rel="noreferrer" target="_blank">www.virtbiz.com</a> | toll-free (866) 4 VIRTBIZ<br>
</span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Blueonyx mailing list<br>
<a href="mailto:Blueonyx@mail.blueonyx.it">Blueonyx@mail.blueonyx.it</a><br>
<a href="http://mail.blueonyx.it/mailman/listinfo/blueonyx" rel="noreferrer" target="_blank">http://mail.blueonyx.it/mailman/listinfo/blueonyx</a><br>
</div></div></blockquote></div><br></div>