]> andersk Git - sql.git/commitdiff
backups write to partitionable AFS volume structure
authorJoe Presbrey <presbrey@mit.edu>
Sun, 18 May 2008 21:20:32 +0000 (21:20 +0000)
committerJoe Presbrey <presbrey@mit.edu>
Sun, 18 May 2008 21:20:32 +0000 (21:20 +0000)
git-svn-id: svn://presbrey.mit.edu/sql@157 a142d4bd-2cfb-0310-9673-cb33a7e74f58

libexec/afs-renew-tickets.sh
libexec/afs-run-backup.php
libexec/afs-set-permissions.php

index 076331e7fcf2ac571e1662da4a04bbdd35d1185a..6f3acd6cd9ce89e9803d41dbf30569c8eeeebce0 100755 (executable)
@@ -1,4 +1,4 @@
 #!/bin/bash
 
-/usr/kerberos/bin/kinit -k -t /root/keytab-sql.mit.edu daemon/sql.mit.edu
+/usr/kerberos/bin/kinit -k -t /root/.keytab-sql.mit.edu daemon/sql.mit.edu
 /usr/bin/aklog
index 609819aecd55f8292eff5d249d10075a746085cf..62572bc4d42a957b6ce05490a07fa2e8a91fc957 100755 (executable)
@@ -1,7 +1,8 @@
 #!/usr/bin/env php
 <?php
 
-$EXCEPTIONS[] = 'presbrey+aol';
+$EXCEPTIONS = explode("\n",file_get_contents('/mit/sql/etc/db_no-daily-backup'));
+$EXCEPTIONS = array_filter($EXCEPTIONS, 'strlen');
 
 ini_set('memory_limit', '-1');
 set_time_limit(0);
@@ -10,14 +11,10 @@ ignore_user_abort(1);
 define('BACKUP_RUN_STATS', 0);
 define('BACKUP_CRON', 1);
 
-$bin_mysql='mysql -umit-backup';// --defaults-file=/afs/athena.mit.edu/user/p/r/presbrey/web/etc/sql-mit-edu.my.cnf';
-$bin_mysqldump='mysqldump -umit-backup';// --defaults-file=/afs/athena.mit.edu/user/p/r/presbrey/web/etc/sql-mit-edu.my.cnf';
+$bin_mysql='mysql -umit-backup';
+$bin_mysqldump='mysqldump -umit-backup';
 $dump_path='/afs/athena.mit.edu/contrib/sql/backup';
-//$dump_exec = "$bin_mysqldump -CefqQK --single-transaction --result-file=$dump_path/%s %s 2>&1";
-//$dump_exec = "$bin_mysqldump -CefqQK --result-file=$dump_path/%s %s 2>&1";
-/* great from linerva:
-$dump_exec = "$bin_mysqldump -CefqQK %s | gzip > $dump_path/%s.sql.gz ";
- */
+$partition_path='/afs/athena.mit.edu/contrib/sql/.backup';
 $dump_exec = "$bin_mysqldump -efqQK %s | gzip > $dump_path/%s.sql.gz ";
 $dump_host=':/srv/mysql/mysql.sock';
 $dump_user='mit-backup';
@@ -27,12 +24,12 @@ $sql_resource = mysql_connect($dump_host,$dump_user,$dump_pass);
 $sql_databases = mysql_list_dbs($sql_resource);
 $stat['nDatabases'] = mysql_num_rows($sql_databases);
 
-@unlink("$dump_path/.skipped");
+@unlink("$partition_path/skipped");
 while($row1 = mysql_fetch_row($sql_databases)) {
        if ($row1[0] == 'information_schema')
                continue;
        if (preg_match('/[^a-z0-9\+_.-]+/i', $row1[0])) {
-               $f = fopen("$dump_path/.skipped",'w');
+               $f = fopen("$partition_path/skipped",'a');
                fwrite($f, "{$row1[0]}\n");
                fclose($f);
        }
@@ -44,29 +41,37 @@ $time[1][0] = microtime(true);
 foreach($databases as $name=>$info) {
        if (in_array($name, $EXCEPTIONS)) {
                if (!BACKUP_CRON)
-                       printf('Skipping EXCEPTIONed database: %s', $name);
+                       printf("Skipping database: %s\n", $name);
                continue;
+       } else {
+               if (!BACKUP_CRON)
+                       printf("Dumping database: %s\n", $name);
        }
        if (stristr($name,'+')) {
-               $owner = array_shift(explode('+',$name)).'/';
-               @mkdir("$dump_path/$owner");
-               `fs sa $dump_path/$owner $owner rl 2>/dev/null`;
-               `fs sa $dump_path/$owner system:authuser none`;
+               $owner = array_shift(explode('+',$name));
        } else {
-               $owner = 'root/';
-               @mkdir("$dump_path/$owner");
-               `fs sa $dump_path/$owner system:authuser none`;
-               `fs sa $dump_path/$owner system:sql-backup none`;
+               $owner = 'root';
        }
-       $exec = sprintf($dump_exec, $name, $owner.$name);
-
-       if ($owner!='root' && file_exists("$dump_path/$owner$name.sql.gz")) {
+       if (!is_link($dump_path.'/'.$owner)) {
+               symlink($partition_path.'/'.substr($owner,0,1).'/'.$owner, $dump_path.'/'.$owner);
+       }
+       if (!is_dir(readlink($dump_path.'/'.$owner))) {
+               mkdir(readlink($dump_path.'/'.$owner));
+       }
+       `fs sa $dump_path/$owner/ system:anyuser none`;
+       `fs sa $dump_path/$owner/ system:authuser none`;
+       if ($owner == 'root') {
+               `fs sa $dump_path/$owner/ system:sql-backup none`;
+       }
+       $exec = sprintf($dump_exec, $name, $owner.'/'.$name);
+/*
+       if ($owner != 'root' && file_exists("$dump_path/$owner/$name.sql.gz")) {
                if (!BACKUP_CRON)
                        printf("Saving old dump file: %s\n",
-                       "$dump_path/$owner$name.sql.gz");
-               rename("$dump_path/$owner$name.sql.gz","$dump_path/OLD/$name.sql.gz");
+                       "$dump_path/$owner/$name.sql.gz");
+               rename("$dump_path/$owner/$name.sql.gz", "$dump_path/OLD/$name.sql.gz");
        }
-
+*/
        if (!BACKUP_CRON)
                printf("Dumping %d of %d / %d%% (%s):\n",
                $i_database,
index af410b95e2ceb948f0100a0ddf67daee8e64e9d9..357dd0f4dc962eefc22978e1bc962ebbd26c608f 100755 (executable)
@@ -15,7 +15,7 @@ foreach($g as $locker) {
                $filsys_type = 'unknown';
        
        if (!isset($logs[$filsys_type]))
-               $logs[$filsys_type] = fopen('.'.$filsys_type, 'w');
+               $logs[$filsys_type] = fopen('/mit/sql/.backup/'.$filsys_type, 'w');
 
        fwrite($logs[$filsys_type], "$locker\n");
 
This page took 0.037373 seconds and 5 git commands to generate.