Previous Thread
Next Thread
Print Thread
Rate Thread
#105051 11/21/2005 12:07 PM
Joined: May 2000
Posts: 1,356
Addict
Addict
Joined: May 2000
Posts: 1,356
you need to know the disk quota for that operation. Currently I don't have access to a linux system and I don't remember the exact command, but there may be some Quota modules on CPAN. And to calculate the approximate dump size, you have to calculate row lengths. I don't know how to get that value from command line, but this query will return the data:

Code
SHOW TABLE STATUS FROM <DATABASE_NAME>;
this'll return a list with a lot of keys. "Data_length" is the one you are looking for. Here is a perl/DBI example:

Code
use DBI;
my $dbname = "your_db_name";
my $dbh = DBI->connect('DBI:mysql:'.$dbname, 'root', '',{RaiseError => 1});
my $sth = $dbh->prepare("SHOW TABLE STATUS FROM $dbname");
$sth->execute;
my $size = 0;
while (my $stat = $sth->fetchrow_hashref) {
$size += $stat->{Data_length};
}
$dbh->disconnect;
printf "Total data size: %.2f KB", $size / 1024;
here $size gives you an approximate value, because a db dump will include more information than data and a lot of insert() etc statements... But it'll give you a value to compare:

Code
$space = $quota - $disk_space_I_currently_use;
# $xtra can be a constant value for insert() statements
if ($space > $size+$xtra) {
# do backup
} else {
# don't
}

Sponsored Links
Entire Thread
Subject Posted By Posted
Help with script 1QuickSI 11/15/2005 8:53 PM
Re: Help with script Burak 11/21/2005 7:07 PM
Re: Help with script Gizmo 11/22/2005 5:36 AM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240430)