| Author |
Message |
amirw
Newbie


Joined: Jan 30, 2005
Posts: 3
|
Posted:
Mon Jan 31, 2005 6:30 am |
|
You've got a great script and I tweaked it so it will work perfectly.
The only problem I saw (except the folder creation mentioned in an earlier thread) was in the auto-backup. Putting the script trigger on footer.php would potentially create multiple backups when several users loaded the same page at the exact second (before the full backup had a chance to be created).
I added a double check to prevent multiple backups, which practically killed my server.
1. Open includes/dump.php
2. Find lines:
| Code: |
$datetime = date('m-d-y@h-ia');
$filename = "$backupdir/$datetime.sql"; |
Add AFTER:
| Code: |
//Added: Re-check to prevent multiple backups at the same time from multiple sessions
if(!$manual == "yes"){
//Check that this backup is not done by another session
$result1 = $db->sql_query("SELECT autostate, autolast, autoinc FROM ".$prefix."_advbackup where id='1'");
$row = $db->sql_fetchrow($result1);
$autostate = $row['autostate'];
$last_back = $row['autolast'];
$autoinc = $row['autoinc'];
if ($autostate == "on"){
$rawtime = time();
if (($rawtime - $last_back) <= ($autoinc * 3600) ) { //Someone else is trying to backup, die after showing foot()
foot();
die();
}
}
$result = $db->sql_query("UPDATE ".$prefix."_advbackup set lastdb='$datetime', autolast='$rawtime' where id='1'"); //Update table BEFORE actual backup to prevent multiple backups.
}
//End of added |
This is not an optimized code. I only did it as a test to make the code work, but the idea is to inform advbackup table that a backup was done BEFORE another user gets the chance to "include" dump.php from footer.php.
That's all.
Another thing that bothers me is that the backup create a huge SQL file (after gzip it's smaller again). Comparing to the backup I used in Direct Admin (site's control panel), the differences in SQL file sizes are like 20mb vs 80mb. After GZip - they are the same size again, but it would be nice to see the original SQL in a smaller size as well.
Great job !
Amir W. |
|
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 722
|
Posted:
Mon Jan 31, 2005 2:36 pm |
|
Thanks for taking the time to work it out, I really appriciate it!
As for the huge sql file......
My next order of business is to optimize the dump script and also add an option to backup the structure and data individually or seperately.
Just to be sure, your database backed up successfully and its 80mb when it should be more like 20mb? Do you notice any repitition in the file? Do you have any clue why its so much bigger than when you backup with your control panel?
Thanks for stopping by |
|
|
|
 |
amirw
Newbie


Joined: Jan 30, 2005
Posts: 3
|
Posted:
Mon Jan 31, 2005 5:31 pm |
|
Yes, this is correct.
I compared three methods of backups:
1. Direct Admin's SQL Backup
2. phpMyAdmin SQL Backup
3. Advanced Nuke Backup
The main differences and probably what's causing the huge size differences are:
1. Direct Admin (Most optimized ~ 20mb)
INSERT into 'table_name' VALUES('row1-fld1','row1-fld2','row1-fld3'),('row2-fld1','row2-fld2','row2-fld3'),('row3-fld1','row3-fld2','row3-fld3'),...(...);
2. phpMyAdmin (Partially optimized ~ 50mb)
INSERT into 'table_name' VALUES('row1-fld1','row1-fld2','row1-fld3');
INSERT into 'table_name' VALUES('row2-fld1','row2-fld2','row2-fld3');
INSERT into 'table_name' VALUES('row3-fld1','row3-fld2','row3-fld3');
3. Advanced Nuke Backup (Not optimized ~ 80mb)
INSERT into 'table_name' ('field_name1', 'field_name2','field_name3') VALUES('row1-fld1','row1-fld2','row1-fld3');
INSERT into 'table_name' ('field_name1', 'field_name2','field_name3') VALUES('row2-fld1','row2-fld2','row2-fld3');
INSERT into 'table_name' ('field_name1', 'field_name2','field_name3') VALUES('row3-fld1','row3-fld2','row3-fld3');
When you have allot of data, this can be very significant for file sizes. Of course I would prefer using option #1.
I didn't restore the backup because I got a timeout from the server, but I intend to split the SQL file into smaller chunks and verify that the backup is valid.
Amir W. |
|
|
|
 |
amirw
Newbie


Joined: Jan 30, 2005
Posts: 3
|
Posted:
Mon Jan 31, 2005 5:50 pm |
|
I couldn't wait - I removed the inclusion of field names from the backup. Filesize was reduced from ~80mb to ~50mb. Very impressive.
Find this line:
| Code: |
| $insert = "INSERT INTO `".$table[$dbname][$t]."` (`".implode("`, `", $fieldnames)."`) VALUES ("; |
Replace with this line:
| Code: |
//Optimized to not show field names and save on file-size
$insert = "INSERT INTO `".$table[$dbname][$t]."` VALUES ("; |
Amir W. |
|
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 722
|
Posted:
Tue Feb 01, 2005 5:21 am |
|
Nice! |
|
|
|
 |
jonmcc33
Newbie


Joined: Jan 25, 2005
Posts: 5
|
Posted:
Wed Feb 02, 2005 11:55 am |
|
Amir, where is that last part changed at? I too had issues with it creating backups like 20 times in an hour. |
|
|
|
 |
nailerpa
Newbie


Joined: Jul 04, 2005
Posts: 1
|
Posted:
Tue Jul 05, 2005 7:54 am |
|
Forgive me if this has already been answered. I have uploaded (complete with the updated dump.php file) and installed ADB 1.1. I have also made the change to the footer.php file. I have configured the backups to run every 24 hrs. However, they are continually running...one right after the other. Am I missing some tweak or updated file? Thanks for your assistance! |
|
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 722
|
Posted:
Tue Jul 05, 2005 1:28 pm |
|
Did you run the anbinstall.php file to install the needed database tables?
You should also read the Advanced Nuke Backup guide here on this site and make sure you installed everything correctly.
If you still have problems after that, let me know and we'll work on getting it fixed |
|
|
|
 |
|
|