Exemplo n.º 1
0
function txDatabaseBackup()
{
    global $DB, $C;
    VerifyAdministrator();
    CheckAccessList();
    $GLOBALS['message'] = DoDatabaseBackup($_REQUEST);
    txShDatabaseTools();
}
Exemplo n.º 2
0
$DB->Connect();
echo "Checking database consistency...\n";
$fields = $DB->GetColumns('tx_galleries', TRUE);
if (isset($fields['newid'])) {
    echo "ERROR: The database is in an inconsistent state.  Please restore from the last known good backup\n";
    exit;
}
echo "Performing database cleanup...\n";
$tables = array('tx_gallery_previews', 'tx_gallery_used', 'tx_gallery_confirms', 'tx_gallery_fields', 'tx_gallery_icons');
foreach ($tables as $table) {
    $DB->Update('DELETE # FROM # LEFT JOIN `tx_galleries` USING (`gallery_id`) WHERE `tx_galleries`.`gallery_id` IS NULL', array($table, $table));
}
echo "Generating database backup...\n";
$tables[] = 'tx_galleries';
$backup_files = array('sql-file' => 'shuffle-sql-backup.txt');
DoDatabaseBackup($backup_files, TRUE);
echo "Locking tables...\n";
$DB->Update('LOCK TABLES ' . join(' WRITE, ', $tables) . ' WRITE');
echo "Generating new gallery IDs...\n";
$DB->Update('ALTER TABLE `tx_galleries` ADD COLUMN `newid` INT');
$DB->Update('SET @ID:=0');
$DB->Update('UPDATE `tx_galleries` SET `newid`=@ID:=@ID+1 ORDER BY RAND()');
$tables = array('tx_gallery_confirms', 'tx_gallery_fields');
foreach ($tables as $table) {
    echo "Updating {$table}...\n";
    $DB->Update('ALTER TABLE # MODIFY COLUMN `gallery_id` INT, DROP PRIMARY KEY', array($table));
    $DB->Update('UPDATE `tx_galleries` JOIN # USING (`gallery_id`) SET #.`gallery_id`=`newid`', array($table, $table));
    $DB->Update('ALTER TABLE # MODIFY COLUMN `gallery_id` INT NOT NULL PRIMARY KEY', array($table));
}
$tables = array('tx_gallery_previews');
foreach ($tables as $table) {
Exemplo n.º 3
0
             BuildTagged($args['tags']);
         } else {
             BuildAll();
         }
     }
     break;
 case '--process-clicklog':
     ProcessClickLog();
     break;
 case '--backup':
     $args = ParseCommandLine();
     if (IsEmptyString($args['sql-file'])) {
         echo "ERROR: You must specify at least a SQL data backup filename when using the --backup function\n" . "Example:\n" . "{$_SERVER['_']} {$path}/{$GLOBALS['argv'][0]} --backup --sql-file=sql-backup.txt --thumbs-file=thumbs-backup.txt --archive-file=backup.tar.gz\n";
         break;
     }
     DoDatabaseBackup($args, TRUE);
     break;
 case '--restore':
     $args = ParseCommandLine();
     if (IsEmptyString($args['sql-file'])) {
         echo "ERROR: You must specify at least a SQL data backup filename when using the --restore function\n" . "Example:\n" . "{$_SERVER['_']} {$path}/{$GLOBALS['argv'][0]} --restore --sql-file=sql-backup.txt --thumbs-file=thumbs-backup.txt\n";
         break;
     }
     DoDatabaseRestore($args, TRUE);
     break;
 case '--export':
     DoGalleryExport(null, TRUE);
     break;
 case '--optimize':
     OptimizeDatabase();
     break;